[Mono-osx] ServicePointManager using 2.0

Duane Wandless duane at wandless.net
Tue Oct 21 10:00:35 EDT 2008


Further investigation points to this being the cause of the NULL reference.

In System.Configuration/ConfigurationManager.cs, function
OpenExeConfigurationInternal() about line 98 you will find:
                                      if (!systemWebInUse &&
calling_assembly != null)
                                                exePath =
calling_assembly.Location;
                                        else
                                                exePath =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
                                        map.ExeConfigFilename =
exePath.EndsWith (".config") ? exePath : exePath + ".config";

As I mentioned in my first post my C# code is in a DLL that is embedded
within in a ObjC app.  I did verify that Assembly.GetEntryAssembly returns
null, which is calling_assembly.  Also
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile returns null for
my DLL.  So the null reference comes from this line:
map.ExeConfigFilename = exePath.EndsWith (".config") ? exePath : exePath +
".config";

My code worked in 1.9.1.  I did see a lot of changes to
ConfigurationManager.cs regarding how to get the path.  I'm not sure what
revision was 1.9.1.  Hopefully someone can look at this code and suggest a
work around or a fix.  Otherwise back to 1.9.1.

Thanks,
Duane

On Mon, Oct 20, 2008 at 8:04 PM, Duane Wandless <duane at wandless.net> wrote:

> I did not have any problems using 1.9.1.  After installing 2.0 I am
> receiving this exception/stack trace (see below) when executing this
> statement:
> ServicePointManager.ServerCertificateValidationCallback += new
> System.Net.Security.RemoteCertificateValidationCallback(CertAuth.TrustAllCertificatesCallback);
>
> CertAuth.TrustAllCertificatesCallback simply returns true and is static.
>
> I receive the same exception when executing this statement:
> ServicePointManager.CertificatePolicy = new CertAuth();
>
> CertAuth implements CheckValidationResult and returns true.
>
> Again this code worked from 1.9.1.  The key point about my code is it is
> running from a DLL that is embedded in a Cocoa application.  Any help would
> be greatly appreciated.
>
> Thanks,
> Duane
>
> Unhandled Exception: System.TypeInitializationException: An exception was
> thrown by the type initializer for System.Net.ServicePointManager --->
> System.Configuration.ConfigurationErrorsException: Error Initializing the
> configuration system. ---> System.NullReferenceException: Object reference
> not set to an instance of an object
>   at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal
> (ConfigurationUserLevel userLevel, System.Reflection.Assembly
> calling_assembly, System.String exePath) [0x00000]
>   at System.Configuration.ClientConfigurationSystem.get_Configuration ()
> [0x00000]
>   --- End of inner exception stack trace ---
>   at System.Configuration.ClientConfigurationSystem.get_Configuration ()
> [0x00000]
>   at
> System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection
> (System.String configKey) [0x00000]
>   at System.Configuration.ConfigurationManager.GetSection (System.String
> sectionName) [0x00000]
>
>
>
>   at System.Net.ServicePointManager..cctor () [0x00000]
>   --- End of inner exception stack trace ---
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20081021/c225cb22/attachment.html 


More information about the Mono-osx mailing list