2011-07-05 5 views
1

私のWebアプリケーションはコンパイルされ、自分のマシンで正常に動作します。しかし私のasp.net Webアプリケーションを公開すると、 'オブジェクト参照がオブジェクトのインスタンスに設定されていません。'というメッセージが表示されます。

_UserName = windowsId.Name.Substring(windowsId.Name.IndexOf('\\') + 1); 
     _DomainName = windowsId.Name.ToString().Remove(windowsId.Name.IndexOf('\\')); 

     //Get users information from active directory 
     DirectorySearcher search = new DirectorySearcher("LDAP://DCHS"); 
     search.Filter = String.Format("(SAMAccountName={0})", _UserName); 
     SearchResult result = search.FindOne(); 
     DirectoryEntry entry = result.GetDirectoryEntry(); 

     _FullName = result.Properties["givenName"][0].ToString() + ' ' + result.Properties["sn"][0].ToString(); 
     _Email = result.Properties["mail"][0].ToString(); 
     _FirstName = result.Properties["givenName"][0].ToString(); 
     _SSID = windowsId.User.ToString(); 

を次のように私はIIS6サーバーに公開するとき、私は次のスタックトレース

[NullReferenceException: Object reference not set to an instance of an object.] 
    ForYourInformation.LDAPDetails..ctor(IntPtr logonToken) in d:\documents\documents\visual studio 2010\Projects\ForYourInformation\ForYourInformation\Utils.cs:66 
    ForYourInformation._Default.Page_Load(Object sender, EventArgs e) in d:\documents\documents\visual studio 2010\Projects\ForYourInformation\ForYourInformation\Default.aspx.cs:24 
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24 
    System.Web.UI.Control.LoadRecursive() +70 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3047 

で悪名高いObject reference not set to an instance of an object.を取得フラグが付けられたファイルUtils.csそれは、ユーザーがアクティブになるとグラブですディレクトリとセキュリティ情報。 66行目はDirectoryEntry行です。私はここで何が起こっているのか分からない。

ご協力いただきありがとうございます。

+0

魔女ライン** Utils.csです:プロジェクト\ ForYourInformation \ ForYourInformation \ Utils.cs \ Visual Studioの2010 \ドキュメント\ \ドキュメント66 ** – Aristos

+0

DirectoryEntryエントリ= result.GetDirectoryEntry(); – Matt

+0

@あなたが@Mattに行くと、検索からの戻り値はnullです。 – Aristos

答えて

1

ここであなたはマットに行く、結果はnullを返します。それを使用する前にそれをチェックしてください。

レポートからの通知方法。この行では、66行目が最初のエラーとnullポインタをスローすることを示しています。したがって、この行では、唯一のnullはの結果になります。ここでは、それを見つけることができます。 Dで

ForYourInformation.LDAPDetails..ctor(のIntPtr logonToken):66

+0

ありがとう – Matt

関連する問題