Discussion:
binding failure on 3rd party assembly - works in Debug, not in Rel
(too old to reply)
Mark
2010-04-14 21:34:06 UTC
Permalink
Raw Message
Hi...

We've got a 3rd party assembly (dtSearchNetApi2.dll) that some of our code
depends on. We're using Visual Studio 2005 to build. Recently I got an x64
box so I've been trying to build our software x64.

Turns out dtSearchNetApi2.dll depends on some native-mode assemblies like
the msvcr80.dll.

When I build in Debug|x64, it builds fine, as I would expect (Visual Studio
having all the dlls). When I switch to Release|x64, I get binding failures
on dtSearchNetApi2.dll - the usual "An attempt was made to load a program
with an incorrect format." error...

On their website, they list some of the packages they depend on and point to
a redist package for download. Looking in my C:\Windows\winsxs directory, I
see packages with *almost* the same signature - e.g.
amd64_microsoft.vc80.atl_1fc8b3b9a1e18e3b_8.0.50727.4053_none_8a1a02152edb659b
vs
amd64_Microsoft.VC80.ATL_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_79404cdd
(in the list on http://support.microsoft.com/kb/973544/)

a) Why is it working fine on Debug|x64 and not on Release|x64?
b) How do I tell which native dll it's not finding in Release|x64?

Thanks
Mark
Jialiang Ge [MSFT]
2010-04-19 01:16:51 UTC
Permalink
Raw Message
Hello

Is your host application (the applicaiton that loads the
dtSearchNetApi2.dll) a managed application or an unmanaged application?
When you say that you build in Debug|x64, are you building the host
application? Does dtSearchNetApi2.dll target ANY CPU?

I propose to first locate the dll that failed to be loaded. I list my
frequently used skills below. Please try them.

1. sxstrace
This only works for sxs binding failures.
SxsTrace Trace -logfile:SxsTrace.etl
SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt

2. dependency walker
http://dependencywalker.com/
This only works for native modules. It has a very powerful function
"Profile" that can trace the loading process and tell you if there's any
errors. It can also check statically the dependencies of the application.
Please try it in your application. It may not work for you.

3. Fusion event log
This only works for .NET assembly binding process.
http://msdn.microsoft.com/en-us/library/e74a18c4(VS.80).aspx

4. Procmon log
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
Use this to trace the file system behaviors of your applicaiton. You can
see from its log that your application loads different dlls. When you
received the error, find in the log the last dll your applicaiton attempts
to load.

5. windbg
Use windbg to debug your application load process. This will definitely
work for you, but it requires some debugging knowledge.

Regards,
Jialiang Ge
Microsoft Online Community Support

=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Mark
2010-04-19 18:00:01 UTC
Permalink
Raw Message
Hi Jialiang...

Thank you for responding.

The code using dtSearchNetApi2.dll is all managed code, compiled Any CPU.
Our code is used in a variety of different applications. Some of it gets
registered with COM interop, some is in ASP.Net .aspx pages, some parts are
in web services.

Specifically my problem building release is that the Visual Studio tasks are
failing.
sgen.exe fails because the webservice dll can't load dtSearchNetApi2.dll
(works in Debug because sgen isn't run).

We have a project with a post-build event to run regasm on the dlls exposing
COM interop, and in Release build regasm also fails trying to load
dtSearchNetApi2.dll. Interestingly, it works in Debug builds.

I tried using sxstrace while doing a build, but nothing showed up in the log
pertinent to this issue.

Using Reflector and Corflags, I determined that
1) The dtSearchNetApi2.dll I'm using is built for x64
2) The only unmanaged dependency in Reflector is MSVCR80.dll In my sxs
directory, I have 5 different x64 versions of this dll.

I don't have separate Release and Debug builds for dtSearchNetApi2.dll; I'm
using the same .dll in both builds. I don't know why regasm can load it in
the Debug build but not in the Release build.

Thanks
Mark
Post by Jialiang Ge [MSFT]
Hello
Is your host application (the applicaiton that loads the
dtSearchNetApi2.dll) a managed application or an unmanaged application?
When you say that you build in Debug|x64, are you building the host
application? Does dtSearchNetApi2.dll target ANY CPU?
I propose to first locate the dll that failed to be loaded. I list my
frequently used skills below. Please try them.
1. sxstrace
This only works for sxs binding failures.
SxsTrace Trace -logfile:SxsTrace.etl
SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt
2. dependency walker
http://dependencywalker.com/
This only works for native modules. It has a very powerful function
"Profile" that can trace the loading process and tell you if there's any
errors. It can also check statically the dependencies of the application.
Please try it in your application. It may not work for you.
3. Fusion event log
This only works for .NET assembly binding process.
http://msdn.microsoft.com/en-us/library/e74a18c4(VS.80).aspx
4. Procmon log
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
Use this to trace the file system behaviors of your applicaiton. You can
see from its log that your application loads different dlls. When you
received the error, find in the log the last dll your applicaiton attempts
to load.
5. windbg
Use windbg to debug your application load process. This will definitely
work for you, but it requires some debugging knowledge.
Regards,
Jialiang Ge
Microsoft Online Community Support
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
.
Jialiang Ge [MSFT]
2010-04-20 01:16:50 UTC
Permalink
Raw Message
Hello

There are two versions of regasm on x64 system:
one is under the C:\Windows\Microsoft.NET\Framework\v2.0.50727 folder,
which is a x86 version of regasm
the other is under the C:\Windows\Microsoft.NET\Framework64\v2.0.50727
folder, which is a x64 version of regasm

Which one are you using?

Can you add /verbose to the regasm command? What output do you see from
regasm when it fails to register the dll in the release build? If you
register the release build dll in a seperate command line, what happens?

Regards,
Jialiang Ge
Microsoft Online Community Support

=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Mark
2010-04-20 16:23:07 UTC
Permalink
Raw Message
Well, I think you hit on it (or part of it anyway)... The build event
running regasm was conditionalized to use the 32-bit or 64-bit version
depending on the platform setting, so I hadn't looked at it again. In the
Configuration Manager, Release for that that project was set to AnyCpu
instead of a specific platform. Correcting that solved the regasm problem.

The other problem appears to be with sgen.exe -
0) it doesn't run under debug builds, so that's why I didn't see it
1) the 32-bit version comes with Visual Studio
2) VS apparently doesn't look for the 64-bit version when building a 64-bit
platform, which it why it blows up.

I guess the only way around the last bit is to uncheck the box in the
project and try to add a conditionalized build event of some sort?

Thanks
Mark
Post by Jialiang Ge [MSFT]
Hello
one is under the C:\Windows\Microsoft.NET\Framework\v2.0.50727 folder,
which is a x86 version of regasm
the other is under the C:\Windows\Microsoft.NET\Framework64\v2.0.50727
folder, which is a x64 version of regasm
Which one are you using?
Can you add /verbose to the regasm command? What output do you see from
regasm when it fails to register the dll in the release build? If you
register the release build dll in a seperate command line, what happens?
Regards,
Jialiang Ge
Microsoft Online Community Support
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
.
Loading...