remoting : object reference not set to an instance of an object ???
-
I create a client remoting. I set a method with the frontcontroller from a client. When I executing the method this message appear : "object reference not set to an instance of an object " Best regards youssef
That means you're trying to invoke a member on a null reference. This could be practically any problem, like not setting a variable to an instance of a class, the remote instance is not being created and proxied to your client, and the list goes on and on. The best way to find the problem is to debug your code and find where the
NullReferenceException
occurs.Microsoft MVP, Visual C# My Articles
-
That means you're trying to invoke a member on a null reference. This could be practically any problem, like not setting a variable to an instance of a class, the remote instance is not being created and proxied to your client, and the list goes on and on. The best way to find the problem is to debug your code and find where the
NullReferenceException
occurs.Microsoft MVP, Visual C# My Articles
-
I put some breakpoint. But when I run in debug mode, an error occur the file.config doesn't exist. Can you help me how can I do for execute the software in debug mode in remoting Best regards youssef
If you're file doesn't exist, then either you hap-hazardly hard-coded the file path (never a good idea) or it doesn't exist in the directory you think it should. Typically, in .NET Remoting you just use the application's .config file (in the same directory as the application with the same name + .config appended, like an app called MyApp.exe would have a file called MyApp.exe.config in the same directory) and then you'd call
RemotingConfiguration.Configure
passing theAppDomain.CurrentDomain.SetupInformation.ConfigurationFile
so that you can keep everything in the same .config file. This is true for both the client and server. If you don't want to do it this way, then you need to code your app so that it can find the file no matter where it is, like usingApplication.StartupPath
in the client application to use the directory where the .exe is located, and then usePath.Combine
to combine that with file.config using the platform-dependent directory separator character. To debug your application, just click the Debug->Start menu. There is more information in the Visual Studio help.Microsoft MVP, Visual C# My Articles
-
If you're file doesn't exist, then either you hap-hazardly hard-coded the file path (never a good idea) or it doesn't exist in the directory you think it should. Typically, in .NET Remoting you just use the application's .config file (in the same directory as the application with the same name + .config appended, like an app called MyApp.exe would have a file called MyApp.exe.config in the same directory) and then you'd call
RemotingConfiguration.Configure
passing theAppDomain.CurrentDomain.SetupInformation.ConfigurationFile
so that you can keep everything in the same .config file. This is true for both the client and server. If you don't want to do it this way, then you need to code your app so that it can find the file no matter where it is, like usingApplication.StartupPath
in the client application to use the directory where the .exe is located, and then usePath.Combine
to combine that with file.config using the platform-dependent directory separator character. To debug your application, just click the Debug->Start menu. There is more information in the Visual Studio help.Microsoft MVP, Visual C# My Articles