[Mono-dev] Assembly.GetEntryAssembly() returns null

Janne Rantala janne.rantala at gmail.com
Wed Jul 26 13:16:23 EDT 2006


2006/7/26, Janne Rantala <janne.rantala at gmail.com>:
>
> Hi,
>
> I've loaded assembly (compiled in VS.NET) in embedded environment. This
> assembly is supposed to work as a client for web service. However this does
> not work because Assembly.GetEntryAssembly returns null when called from
> managed code. This causes ConfigurationManager to throw ArgumentException
> stating that "exePath must be specified when not running inside a stand
> alone exe".
>
> MSDN
> http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.getentryassembly.aspxsays that
>
> "Return Value
> The Assembly that is the process executable in the default application
> domain, or the first executable that was executed by
> AppDomain.ExecuteAssembly. Can return a null reference (Nothing in
> Visual Basic) when called from unmanaged code."
>
> But since this call is made from managed code it should return something
> else than null? Both Assembly.GetCallingAssembly() and
> Assembly.GetExecutingAssembly return the assembly I've loaded.
>
> Is this a bug?
>
> Here's the full stack trace if it's any help:
>
> Unhandled Exception: System.TypeInitializationException : An exception was
> thrown
>  by the type initializer for System.Net.WebRequest --->
> System.ArgumentException
>
> : exePath must be specified when not running inside a stand alone exe.
>   at
> System.Configuration.ConfigurationManager.OpenExeConfigurationInternal(Con
> figurationUserLevel userLevel, System.Reflection.Assemblycalling_assembly, Syst
> em.String exePath) [0x00000]
>   at
> System.Configuration.ClientConfigurationSystem.System.Configuration.Interna
> l.IInternalConfigSystem.GetSection (System.String configKey) [0x00000]
>   at System.Configuration.ConfigurationManager.GetSection (System.Stringsection
> Name) [0x00000]
>   at System.Net.WebRequest..cctor () [0x00000] --- End of inner exception
> stack
> trace ---
>
>   at <0x00000> <unknown method>
>   at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest (
> System.Uri u
> ri) [0x00000]
>   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest (
> System.U
> ri uri) [0x00000]
>   at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(System.
> Uri uri) [0x00000]
>   at
> System.Web.Services.Protocols.SoapHttpClientProtocol.GetRequestForMessage(
> System.Uri uri, System.Web.Services.Protocols.SoapClientMessage message)
> [0x0000
> 0]
>   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (
> System.String
> method_name, System.Object[] parameters) [0x00000]
>   at WSTest.net.xmethods.www.CurrencyExchangeService.getRate (
> System.String coun
> try1, System.String country2) [0x00000]
>   at (wrapper remoting-invoke-with-check)
> WSTest.net.xmethods.www.CurrencyExchan
> geService:getRate (string,string)
>   at WSTest.Class1.WebServiceTest () [0x00000]
>
> Cheers,
>
> Janne
>

Looks like the only place entry assembly is being set is
mono_runtime_exec_main, which means that every time object is created I must
also call Main method. Is this the way it is supposed to be? I'd imagine
especially in embedded environment objects would be created without calling
Main methods at all.

Doing the mono_runtime_exec_main -call solves problem having
GetEntryAssembly returning null and it also sets the
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.

Janne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060726/d22524e5/attachment.html 


More information about the Mono-devel-list mailing list