私は初心者ですWCF
ので、ご容赦ください。
サービスで新しいオブジェクトNullReferenceException occured
を作成しようとすると、なぜが取得されるのでしょうか。DateTime
WCF
これはコード行です:
DateTime fromDate = new DateTime(DateTime.Now.Ticks);
私は次のようなさまざまなアプローチを試しました。
DateTime fromDate = new DateTime();
DateTime fromDate = DateTime.Now;
3行のコードすべてでNullReferenceException occured
エラーが発生します。
スクリーンショット:
DateTime
でオブジェクトを使用できますWCF
か?
編集:
その行までのコード:
public class CampaignSchedulePlacementService : ICampaignSchedulePlacementService
{
public PlacementAdvertRoutingAddressPairsResponce GetPlacementAdvertRoutingAddressPairs(string userName, string password, string routingAddressCode, int monthsBack, int monthsAhead)
{
return GetPlacementAdvertRoutingAddressPairsByFilters(userName, password, routingAddressCode, monthsBack, monthsAhead);
}
#region Methods
private PlacementAdvertRoutingAddressPairsResponce GetPlacementAdvertRoutingAddressPairsByFilters(string userName, string password, string routingAddressCode, int monthsBack, int monthsAhead)
{
PlacementAdvertRoutingAddressPairsResponce placementAdvertRoutingAddressPairsResponce = new PlacementAdvertRoutingAddressPairsResponce();
StagingEntityModel stagingEntityModel = null;
try
{
try
{
string connectionString = WebConfigurationManager.ConnectionStrings["Test"].ConnectionString;
stagingEntityModel = new StagingEntityModel(RMS.Common.Core.Public.GetEntityConnectionString(connectionString, "Data.EntityFramework.Model.StagingEntityModel"));
stagingEntityModel.Connection.Open();
}
catch (Exception ex)
{
placementAdvertRoutingAddressPairsResponce.Message = "Failed opening the connection :" + String.Format("{0}\r\n with an inner exception of {1}\r\nand a stack trace of {2}", ex.Message,
ex.InnerException != null ? ex.InnerException.Message : "",
ex.StackTrace);
return placementAdvertRoutingAddressPairsResponce;
}
User currentUser = stagingEntityModel.User.FirstOrDefault(x => x.UserName == userName && x.Password == password);
if (currentUser != null)
{
DateTime fromDate = new DateTime(DateTime.Now.Ticks); //.AddMonths(monthsBack * -1);
DateTime toDate = new DateTime(DateTime.Now.Ticks); //.AddMonths(monthsAhead);
編集:
コールスタック: