2011-11-21 40 views
1

我正在Windows应用程序在C#中。我在.NET框架3.5中做了一个应用程序,我使用的是Windows Vista。当我正在构建该应用程序并尝试运行其他机器有Windows 7,它不工作。目标机器在控制面板中显示.NET Framework 4.0客户端配置文件。每当我试图从配置文件中读取一些值时,都会出现此问题。如果我没有使用配置文件,那么我的应用程序将运行但我必须使用配置文件。 对于检查框架问题,我做中,我想读上按一下按钮配置文件值MessageBox.Show(ConfigurationManager.AppSettings["FlagForArchiving"].ToString()); 一个简单的应用程序,但我得到的错误作为阅读配置文件无法在另一台计算机上工作

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box. 

************** Exception Text ************** 
System.NullReferenceException: Object reference not set to an instance of an object. 
    at TestFramework.Form1.button1_Click(Object sender, EventArgs e) 
    at System.Windows.Forms.Control.OnClick(EventArgs e) 
    at System.Windows.Forms.Button.OnClick(EventArgs e) 
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
    at System.Windows.Forms.Control.WndProc(Message& m) 
    at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
    at System.Windows.Forms.Button.WndProc(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 


************** Loaded Assemblies ************** 
mscorlib 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300) 
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll 
---------------------------------------- 
TestFramework 
    Assembly Version: 1.0.0.0 
    Win32 Version: 1.0.0.0 
    CodeBase: file:///C:/Users/mvi/AppData/Local/Temp/Temp1_test.zip/Release/TestFramework.exe 
---------------------------------------- 
System.Windows.Forms 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.235 built by: RTMGDR 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll 
---------------------------------------- 
System.Drawing 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.1 built by: RTMRel 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll 
---------------------------------------- 
System 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.236 built by: RTMGDR 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll 
---------------------------------------- 
System.Configuration 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100) 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll 
---------------------------------------- 
System.Xml 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.233 built by: RTMGDR 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll 
---------------------------------------- 

************** JIT Debugging ************** 
To enable just-in-time (JIT) debugging, the .config file for this 
application or computer (machine.config) must have the 
jitDebugging value set in the system.windows.forms section. 
The application must also be compiled with debugging 
enabled. 

For example: 

<configuration> 
    <system.windows.forms jitDebugging="true" /> 
</configuration> 

When JIT debugging is enabled, any unhandled exception 
will be sent to the JIT debugger registered on the computer 
rather than be handled by this dialog box. 

请帮我解决我的problem.Thanks提前。

+1

您是否将您的配置文件复制到其他机器上?你遇到了什么错误? – zmbq

+9

你能写出确切的错误日志,以便我们调查吗? –

+0

@zmbq:构建该应用程序之后是否需要单独的复制配置文件到其他机器?我的配置文件有一些值为 而且每当我尝试运行我的应用程序时,它给出的错误为FileNotFoundException – Dany

回答

2

FileNotFoundException表示该配置文件不存在于您的应用程序文件夹中。确保在发布应用程序时配置文件已部署。

是的,您需要在安装应用程序的每台机器上都有一个配置文件。

0

可能是因为目录访问。通过管理员运行您的应用程序以保证访问

+0

我也这样做,但它不工作 – Dany

0

将配置文件更改为“.NET Framework 3.5”。 “.NET Framework 3.5客户端配置文件”有一些限制,不会提供您可能需要的所有程序集。

+0

谢谢,但我的目标机器有Windows 7,我想在Windows 7中已经安装了.NET Framework 3.5。 – Dany

+0

@Dany但是你说过,Windows 7机器在控制面板中显示了.NET Framework 4.0 Client Profile。当您使用“.NET Framework 3.5”配置文件构建应用程序时,可能不包含您需要的部分。 – Fischermaen

+0

Ya仅在控制面板中显示.NET Framework 4.0客户端配置文件,但未显示.NET Framework 3.5 – Dany

相关问题