Assembly binding problem

G

Guest

I have several ASP.NET applications with near identical web.config files. In
one of them I am successfuly able to bind to an assembly while on others I am
not.

All of them have the following qualifiers:

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="OrderDynamics.ImageService.Interfaces"
fullName="OrderDynamics.ImageService.Interfaces,Version=1.0.0.0,Culture=neutral,PublicKeyToken=663065290036ba4e"/>
</assemblyBinding>
</runtime>

Using fusionlogvw, I can see that in the working app it is succesfuly using
the web.config file:

*** Assembly Binder Log Entry (2/27/2006 @ 2:57:41 PM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_wp.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = STEVENDOTNET\ASPNET
LOG: DisplayName = OrderDynamics.ImageService.Interfaces
(Partial)
LOG: Appbase = file:///C:/Visual Studio Projects/Nutrazone/Liposlim/
LOG: Initial PrivatePath = C:\Visual Studio Projects\Nutrazone\Liposlim\bin
LOG: Dynamic Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
ASP.NET Files\liposlim\408be0eb
LOG: Cache Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
ASP.NET Files\liposlim\408be0eb
LOG: AppName = 17777a67
Calling assembly : Business Logic, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=e07d99407b976026.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Visual Studio
Projects\Nutrazone\Liposlim\web.config
LOG: Using host configuration file:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Partial reference qualified from config file. New reference:
OrderDynamics.ImageService.Interfaces, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=663065290036ba4e.
LOG: Binding succeeds. Returns assembly from
C:\WINDOWS\assembly\GAC_MSIL\OrderDynamics.ImageService.Interfaces\1.0.0.0__663065290036ba4e\OrderDynamics.ImageService.Interfaces.dll.
LOG: Assembly is loaded in default load context.


However the non working app shows:
*** Assembly Binder Log Entry (2/27/2006 @ 2:54:56 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_wp.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = STEVENDOTNET\ASPNET
LOG: DisplayName = OrderDynamics.ImageService.Interfaces
(Partial)
LOG: Appbase = file:///C:/Visual Studio Projects/Nutrazone/AdminUI/
LOG: Initial PrivatePath = C:\Visual Studio Projects\Nutrazone\AdminUI\bin
LOG: Dynamic Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
ASP.NET Files\adminui\a7112056
LOG: Cache Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
ASP.NET Files\adminui\a7112056
LOG: AppName = dd7b5eda
Calling assembly : Business Logic, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=e07d99407b976026.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Visual Studio
Projects\Nutrazone\AdminUI\web.config
LOG: Using host configuration file:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Attempting download of new URL
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET
Files/adminui/a7112056/dd7b5eda/OrderDynamics.ImageService.Interfaces.DLL.
LOG: Attempting download of new URL
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET
Files/adminui/a7112056/dd7b5eda/OrderDynamics.ImageService.Interfaces/OrderDynamics.ImageService.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/Visual Studio
Projects/Nutrazone/AdminUI/bin/OrderDynamics.ImageService.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/Visual Studio
Projects/Nutrazone/AdminUI/bin/OrderDynamics.ImageService.Interfaces/OrderDynamics.ImageService.Interfaces.DLL.
LOG: Attempting download of new URL
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET
Files/adminui/a7112056/dd7b5eda/OrderDynamics.ImageService.Interfaces.EXE.
LOG: Attempting download of new URL
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET
Files/adminui/a7112056/dd7b5eda/OrderDynamics.ImageService.Interfaces/OrderDynamics.ImageService.Interfaces.EXE.
LOG: Attempting download of new URL file:///C:/Visual Studio
Projects/Nutrazone/AdminUI/bin/OrderDynamics.ImageService.Interfaces.EXE.
LOG: Attempting download of new URL file:///C:/Visual Studio
Projects/Nutrazone/AdminUI/bin/OrderDynamics.ImageService.Interfaces/OrderDynamics.ImageService.Interfaces.EXE.
LOG: All probing URLs attempted and failed.


One line that pops out is
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).


How do I find out why it is not applying the policy?
 
G

Guest

I should also add that the assembly is in the GAC and if I drop it in the bin
directory it works fine.
 
S

Steven Cheng[MSFT]

Hi Steven,

So have you got it working now? As for the "qualifyAssembly", it just used
to help redirect a partial assembly reference (ususally for dynamic
assembly loading) to a Full qualified assembly reference. And as long as
the web.config file is correctly configured, in your case, since the
assembly is a strong-named one, the runtime should always start searching
in the GAC, then through the normal assembly probing path( the bin sub dir
for ASP.NET web application).

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

Hi Steven,

This one IIS instance only works when the assembly is in the BIN folder, if
it is not, the qualifiedAssembly element seems to have no affect.
 
S

Steven Cheng[MSFT]

Thanks for your response Steven,

Seems a bit strange. Are you dynamically use Assembly.Load to load the
assembly. Also, is any other simple strong-named assembly suffering the
same problem if use the qualifiedAssembly setting in the applccation or in
any other .net application on that machine?

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

Hi Steven,

I am using Activator.GetObject along with .NET remoting to load the assembly.

There are other strong named assemblies that are loading properly. There
seems to be a bug with the .NET remoting configuration where you can't use a
fullname to specify the assembly, so the workaround is to use the
qualifiedAssemblues
 
S

Steven Cheng[MSFT]

Thanks for your response,

Then, the problem is somewhat specific to .NET remoting scenario. Is it the
server app or the client app? Based on my research , when configure service
object for remoting, we can provide their full qualified name in
application config file.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

Steven,

If I use the following config:

<system.runtime.remoting>
<application>
<channels>
<channel ref="http" useDefaultCredentials="true" port="0">
<clientProviders><formatter ref="binary"
typeFilterLevel="Full"/></clientProviders>
</channel>
</channels>
<client>
<wellknown url="http://10.1.0.24:80/ImageService/ImageService.rem"
type="OrderDynamics.ImageService.Interfaces.IImageService,OrderDynamics.ImageService.Interfaces,Version=1.0.0.0,Culture=neutral,PublicKeyToken=663065290036ba4e"/>
</client>
</application>
</system.runtime.remoting>


I get the following exception which states you can't have version
information in the assembly name.

Exception Details: System.Runtime.Remoting.RemotingException: .Config file
'C:\Visual Studio Projects\Nutrazone\AdminUI\web.config' cannot be read
successfully due to exception 'System.Runtime.Remoting.RemotingException:
Version information is present in the assembly name
'OrderDynamics.ImageService.Interfaces,Version=1.0.0.0,Culture=neutral,PublicKeyToken=663065290036ba4e' which is not allowed for 'client wellknown' entries.
at
System.Runtime.Remoting.Activation.RemotingXmlConfigFileParser.ReportError(String errorStr, RemotingXmlConfigFileData configData)
at
System.Runtime.Remoting.Activation.RemotingXmlConfigFileParser.ReportAssemblyVersionInfoPresent(String
assemName, String entryDescription, RemotingXmlConfigFileData configData)
at
System.Runtime.Remoting.Activation.RemotingXmlConfigFileParser.ProcessClientWellKnownNode(ConfigNode
node, RemotingXmlConfigFileData configData, RemoteAppEntry remoteApp)
at
System.Runtime.Remoting.Activation.RemotingXmlConfigFileParser.ProcessClientNode(ConfigNode node, RemotingXmlConfigFileData configData)
at
System.Runtime.Remoting.Activation.RemotingXmlConfigFileParser.ProcessApplicationNode(ConfigNode node, RemotingXmlConfigFileData configData)
at
System.Runtime.Remoting.Activation.RemotingXmlConfigFileParser.ParseConfigNode(ConfigNode rootNode)
at
System.Runtime.Remoting.RemotingConfigHandler.LoadConfigurationFromXmlFile(String filename)'.
 
S

Steven Cheng[MSFT]

Thanks for response Steven,

Yes, I know the exception you mentioned, this is because you're using
<activated> object in your remoting server application, because for
<activated> type remote object, the version is determined by client
side(client side create the instance of which version, then the server
should create the instance of the corresponding version), there is no
needed to specify version info.(and it force us not to specify version in
server application's config file for activated type). However, we can
specify the version info for the activated type object in client
application's application config file, have you tried this?

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

Hi Steven,

That makes sense (as to why I don't need the full type info on the client),
however I am enumerating the GetRegisteredWellKnownClientEntries() collection
and when the full version info is not known, the ObjectType property of the
WellKnownClientTypeEntry is null which causes a problem when using
Activator.GetObject(type, entry.ObjectUrl)
 
S

Steven Cheng[MSFT]

Thanks for response,


Activator.GetObject is used for get WellKnown object rather than client
activated objects. WellKnow object's version is controled by server-side
while activated object's version is controlled by client-side. This is the
difference which determine whether we should specify the version info at
server-side or client-side's configuration file.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

This does nothing to explain why it works in a few sites and doesn't in
others (on the same machine).

All of my research shows that ObjectType will be null if the runtime is not
able to load the assembly. My binding logs show that the runtime is skipping
my web.config file.
 
S

Steven Cheng[MSFT]

Thanks for your followup Steven,

So I'd like to confirm the object's configured type on your server, is it a
wellknown object or activated object? They'll have different behavior and
configuration.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top