.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Problem with HijriCalendar class

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :.NET Framework
The minimum supported date for HijriCalendar class is 1/1/1 which is equivalent to the gregorian date of July 18th, 622. Now when I try to pass that date to HijriCalendar.GetYear with HijriAdjustment set to -1 I get the following exception  [ArgumentOutOfRangeException: Valid values are between 1 and 9666, inclusive. Parameter name: year] System.Globalization.HijriCalendar.GetDaysInYear(Int32 year, Int32 era) +5405139 System.Globalization.HijriCalendar.GetDatePart(Int64 ticks, Int32 part) +199 System.Globalization.HijriCalendar.GetYear(DateTime time) +41 Here is the code to reproduce the problem: private static void TestHijriAdjustment(int adjustment) { HijriCalendar calendar = new HijriCalendar() { HijriAdjustment = adjustment }; try { Console.WriteLine("HijriAdjutment = {0}, Year = {1}", adjustment, calendar.GetYear(calendar.MinSupportedDateTime)); } catch(ArgumentOutOfRangeException ex) { Console.WriteLine("HijriAdjutment = {0}, Exception: {1} ", adjustment, ex.Message); } } static void Main(string[] args) { TestHijriAdjustment(-2); // Prints Year = 0!! Why doesn't it throw an exception? TestHijriAdjustment(-1); // Throws exception TestHijriAdjustment(0); // Prints Year = 1 TestHijriAdjustment(1); // Prints Year = 1 TestHijriAdjustment(2); // Prints Year = 1 } Now the reason I want minimum supported date t

View Complete Post

More Related Resource Links

Problem with Scripter class in powershell

tweaked my wits on this one. can't figure it out!i'm trying to follow the steps at the bottom of this page http://www.mssqltips.com/tip.asp?tip=1842  [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO')| out-null # Create an SMO connection to the instance$s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST\SQL2005_1" $dbs = $s.Databases$dbs["Northwind"].Script() | Out-File D:\PSScripts\NWind.SQL $scrp = new-object ('Microsoft.SqlServer.Management.Smo.Scripter') ($s) $scrp.Options.AppendToFile = $True$scrp.Options.ClusteredIndexes = $True$scrp.Options.DriAll = $True$scrp.Options.ScriptDrops = $True$scrp.Options.IncludeIfNotExists = $True$scrp.Options.IncludeHeaders = $True$scrp.Options.ToFileOnly = $True$scrp.Options.Indexes = $True$scrp.Options.WithDependencies = $True $scrp.Options.FileName = "D:\PSScripts\NWind.SQL"$scrp.Script($dbs["Northwind"].Tables) I changed the instance, database, and file paths[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null $s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST"  $dbs=$s.Databases #$dbs["AdventureWorks"].Script()  $dbs["AdventureWorks"].Script() | Out-File C:\temp\myscript.SQL   $scrp = new-object ('Microsoft.SqlServer.Manag

Sending Array of Custom Class over WCF Problem

I have been attempting to convert some service calls that returned a DataSet into something more lightweight. For instance, I am converting: [OperationContract] public DataSet GetCommittees(); into: [OperationContract] public List<VolunteerCommittee> GetCommittees(); where committee is defined as: [DataContract] public class VolunteerCommittee { [DataMember] public int Id { get; set; } [DataMember] public String Name { get; set; } } I copied the structure of the data contract and the operation contract right from an example in a book I bought on WCF. The author mentioned that the List<VolunteerCommittee> would get converted into an array over the wire, so the client's operation contract looks like: [OperationContract] public VolunteerCommittee[] GetCommittees(); My problem: When the service is called, an empty array is returned every time. When I put trace statements in, I see an array of 48 VolunteerCommittees leaving the server. I've done some reading on the problem and tried a number of suggestions, such as using the XmlSerializer attribute, including a certain namespace as a [return:] on the server's contract, changing the type of binding (it's using wsHttpBinding... I tried basicHttpBinding) and turning off MTOM in the behavior, but none of these changed the empty result of the call. At this point, I'm hoping someone can shine some light on

Dithering problem with Bitmap class

I have a scanned document(black and white in color), which is typed through a word processor. So, I each letter is very crisp in the image and is not overlapping with any other character. But once I load that into Bitmap class I see that because of dithering the words get connected by gray color.   How can i make sure, that when we are loading the image in Image or Bitmap class we can avoid dithering at all. It means that if the system can find the exact color then map it otherwise leave the pixel untouched and dont fill any color(let's say leave it as white).  suneeelid2000@gmail.co

problem in newform.aspx override class

Hi All Im facing a wierd problem, I have a custom list, im trying to override its newform.aspx page class with custom class. in Page_load event of the class Im checkig for one value in query string, if value exists then I have to select a dropdown field in the list. other wise not to select any value. After that i save the record.  Here only the PROBLEM comes. when I use my code it is NOT inserting new record. When I comment my code it is inserting new record. I do not understand whats the problem in my code. PLEASE help me to overcome this. Here is the code protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //When ERID is not null, it means request is coming from employee page if (HttpContext.Current.Request.QueryString["ERID"] != null) { FinishMyJob(); } } private void FinishMyJob() { SPSecurity.RunWithElevatedPrivileges(delegate() { string _StaffAppRecId = null; Boolean _IsFound = false; SPWeb _web = SPContext.Current.Web; SPList _list = _web.Lists[SPContext.Current.ListId]; SPList _lstEmp = _web.Lists["Employee"]; SPListItem _EmpLstItem = _lstEmp.GetItemById(Convert.ToInt32(HttpContext.Current.Request.QueryString["ERID"])); string _strEmpName = Convert.ToStri

Problem in debugging a class library


When I try to debug a class library I am getting an warning message "Unable to automatically step into the server. Connecting to the server machine 'xxxx.xxx' failed. The debugger cannot connect to the remote computer. This may be because the remote computer does not exist or firewall may be preventing communication to the remote computer. Please see help for assistance."

After getting this message my application shows the result set from the web service. I am not trying to debug the web service application, but trying to debug my code which is in another project in the same solution. Also I have added the project reference from my test application not the dll reference. I've checked the windows firewall and added exception for port 80 also.

Any help in this regard will be greatly appreciated.




spmetal generated class and content type (for page layout) retrieve problem


I'm working with a console application to generate my sites and subsites (hierarchy). And i've got a problem with a generated spmetal class.


this doesn't work:


static void Main(string[] args)


            string SITE = string.Concat("http://"Environment.MachineName);         



Unusual problem using a class method


I have a class that runs calculations on numbers and populates the results to my SQL database.  My code behind page instantiates the class object, and in a loop it makes use of the method five times (once per loop).  Essentially, my code behind collects the information from controls and passes the information to the class method for processing.  The method works just fine most of the time.

On one of the iterations I get a error before the code even gets to the class.  The error is, "Arithmetic operation resulted in an overflow."  What strikes me as odd is that while stepping through the code, the loop crashes with that error before getting to the class that runs the calculations.  Additionally, no arethmetic operations are performed on the form's code-behind page (which calls the method).  I even put a break-point on the class constructor but the code crashed before reaching that constructor.

The information being sent is the results of matches from a sporting event.  As a troubleshooting measure I changed the order of the matches by deleting them an re-entering them into the database in a different order.  Again only this one particular match crashed.

Here is the code that crashes:

cRating.SetRating(dMatchDate, iSetID, 8, iHPlayerID, 

Problem with class hierarchy in MVC app



What have I omitted in setting up my MVC project correctly ?

When I use an imports statement, at the top of my controller(s), I have to repeat the project name twice in order to include my model :

Imports PartInvitations.PartInvitations.Models






2010 Collection class syntax/property problem

I converted a project from 2008 to 2010 to be able to use the TPL.

I've updated the compile target to .NET 4. Everything seems good, including the .NET 4 specific TPL stuff...except that:

Parallel.ForEach(MyClassCollection.Cast(Of MyClass), (Sub(ANYTHING As MYClass) ANYTHING.MySubRoutine()))

Gives the following as a syntax error:

Error 2 'Cast' is not a member of 'Microsoft.VisualBasic.Collection'. C:\Users\jeff\Documents\Visual Studio 2010\Projects\MyProject\MyProject\RunLoop.vb 229 34 MyProject

Any ideas?


Problem retrieving bit colum with sqldatareader for vb class property


 I have a vb class that reads a single row of data from an SQL view. I want to add a property to it that will expose the value of a new bit field. But whatever I do my class always returns the value "false".

What am I doing wrong?

       Public ReadOnly Property IsPublished() As Boolean
                Return valPublished
            End Get
        End Property

Here's the relevant line from my datareader:
        Me.valPublished = Convert.ToBoolean(theObjectReader("Authorised"))Authorised is my bit field. I have tried it with and without the "ConvertToBoolean" statement.
When I response write the value of the property for rows where this field is true, it always shows false.

Any ideas?

Problem with adding custom propety to a data class using Linq.



I tried to add a custom property to the data model:

public partial class Department
        public string ExtensionIdName
                return Extension.ExtensionName;

It seems that it works, but when I bind the data to a ListView it shows all the properties except the property I added manualy (ExtensionIdName).

Am I missing something or is there something wrong?

Problem with class files


using vs2010

I created an empty web site project and I'd like to use my own DAL to interact with a SQL Database. 

My class file looks like the following:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace BatiksGalore
  public class Calendar
  public SqlDataReader GetEventsByDate (string date)


I don't know why but the IDE won't let me construct methods this way. There's a squiggly line under 'SqlDataReader' and the error is 'Expected class, delegate, enum, struct, ...etc.'

I've done this before on Web Site projects and it works fine. Normally intellisense allows me to choose 'SqlDataReader' but in this project (which I've never used before, BTW) I don't have the option.

Any help is appreciated.

an old class and a new problem in donet


i tried to update a table in sql server2000(localhost) by using   static method   


            string constr = "Server=(local);Database=Museum;uid=sa;pwd=123456;";
            string TableName = "WujTest";
            SqlCommand insertcom = new SqlCommand("", new SqlConnection(constr));
            SqlCommand deletecom = new SqlCommand("", new SqlConnection(constr));
            SqlCommand updatecom = new SqlCommand("", new SqlConnection(constr));

            Microsoft.ApplicationBlocks.Data.SqlHelper.UpdateDataset(insertcom, deletecom, updatecom, Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(constr, CommandType.Text, "SELECT * FROM " + TableName), TableName);
and i am sure the connectingstring is enabled, the  table in database("Museum") named "WujTest" has records.

but when run

it throw Exception:


System.InvalidOperationException: Update can ont find TableMapping['WujTest'] ? DataTable"WujTest"?

I am a intern student from C

Function pulls PCs along with users. Wrong Class? Problem with AD setup?


I am creating a web app that interacts with AD. The issue that I have is I am trying to get all users in our domain  and the code I'm using seems to pull all the users however is also seems to be pulling all the PC names as well and I cannot seem to figure out why. Not sure if this will tell you anything but the PC names seem to be ending with a $ sign. ie a PC named LAB comes out in my list as LAB$.

    Public Function UpadateEmployees() As Boolean
        Dim boolreturn As Boolean
        Dim strADUser As String = ConfigurationManager.AppSettings("ADUser")
        Dim strADPass As String = ConfigurationManager.AppSettings("ADPassword")
        Dim entry As New DirectoryEntry(_path, strADUser, strADPass)
        Dim search As New DirectorySearcher(entry)
        search.Filter = "(objectClass=User)"

        ' Declare objects
        ' Loop
        For Each result As SearchResult In search.FindAll()

                Dim dirEntry As Directory

Class problem


Hi All

I have the following code:

Dim storeArray As Store() = Nothing
storeArray = service.GetStoreFinderPostcode(postcodeOuter, postcodeInner, [region], halal, startRecord, 10, "50")

The Store class is contained within an encrypted DLL I don't have access to.

My goal is to return another value using this class.

The problem is that the variable is not contained within this inaccessible class for me to reference.

I have attempted to recreate the class (in the page the above code is in) and use this instead of the class contained within the inaccessible DLL.

Doing this returns the following error:

BC30332: Value of type '1-dimensional array of [DLL name].Store' cannot be converted to '1-dimensional array of ASP.[Page name].Store' because '[DLL name].Store' is not derived from 'ASP.[Page name].Store'.


I hope I have explained things OK - do let me know if you need any more info in order to help me.



System.ServiceModel.Channels.Message class problem in work flow persistence


I have used following link to create a workflow to call web service(asmx) in workflow rehosting.


I have created the workflow successfully. But when i run the workflow and workflow goes for persistence it shows following pesistence related errors.

1.The execution of the InstancePersistenceCommand named {urn:schemas-microsoft-com:System.Activities.Persistence/command}SaveWorkflow was interrupted by an error.

2.Type 'System.ServiceModel.Channels.StreamedMessage' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types."

I think this error is related to serialization of Message class.

Can anyone suggest?




Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend