In a web application I can't debug an assembly, but I can debug some others.
I have a tool that build some assemblies on a network path using CSC (with /debug param) and at the end of the compilation assemblies and pdbs are copied in the local site bin folder; for example are build two assemblies:
webui.dll
webbiz.dll
I have a middle assembly webframework.dll used from webui and webbiz that shows some methods used from them.
The situation when I'm facing the issue is the following:
from an httphandler I call a method of webui.dll using Assembly.Load, here I can debug webui's methods
following the code I call a method of webframework, here I can debug its methods too
following the code I call a webframework method, that handle other assemblies calls; here from a delegate is called a webbiz method using Assembly.LoadFile...here I can debug webframework methods, but not webbiz
Here I'm totally confused, and I can't find a solution.
Some info:
the webapp is runnig under IIS not IIS express
all assemblies are compiled for the debug and pdbs are fresh and not corrupted
if I try to Step Into the webbiz method I see The application in in break mode and I must hit Continue execution
I'm using VS2015, with VS2013 was working fine (!)
it's an ASP .NET related issue, because if I try to reproduce the issue on a console application I can debug
if I put the webbiz assembly in a path different from bin I can debug!
The only way I found to solve the issue is to use Assembly.UnsafeLoadFrom instead of Assembly.LoadFile
Related
I have created a .NET Framework 4.7.2 website with a WCF service. To expose data through this service, I have to reference a third party DLL with Copy Local = False from C:\InstallLocation. The website is loading this DLL at runtime, but I get an error when accessing functionality in the DLL that requires it to load a secondary DLL in the same InstallLocation folder. I verified with Process Monitor that W3WP.exe is finding the primary DLL at C:\InstallLocation, but that W3WP.exe fails to look in C:\InstallLocation at all for the secondary DLL. The application error is the expected,
Could not load file or assembly '[assembly-info-ommitted]' or one of its dependencies. The system cannot find the file specified.
I also tested the exact same type of reference in a Console Application which worked without issue. Process Monitor showed the executable looking in C:\InstallLocation for the secondary DLL.
Is there a way to configure the .NET web app to allow the process to look in the same directory as the referenced, primary DLL? I have tried the following without (full) success:
Adding C:\InstallLocation to my system Path (and restarted). Seemed to have no affect. I verified on application start that the added path did appear in Environment.GetEnvironmentVariable("PATH").
Moved C:\InstallLocation into my web root and tried <probing privatePath="CopiedLocation". This got past the initial DLL reference issues, but still showed an error but on a different dependency for a different DLL. I don't think this will be a viable workaround.
Movied C:\InstallLocation to the bin folder and commented out . Same result as the above.
Gave the app pool user full permission to C:\InstallLocation. Users: IIS APPPOOL\{web site name}, IUSR, IIS_IUSRS
Edit
I have implemented an initializer as shown here, https://stackoverflow.com/a/16867088/2544926. I have changed the code to check if a DLL exists in C:\InstallLocation to load the DLL from that folder. From Process Monitor output, it would seem this is getting me closer. However, I am seeing an error later in the process. Here is the error that I am seeing now (multi-level exception).
The type initializer for '<Module>' threw an exception.
A nested exception occurred after the primary exception that caused the C++ module to fail to load.
The type initializer for '<Module>' threw an exception.
The C++ module failed to load during vtable initialization.
Could not load file or assembly 'XYZ, Version=N.N.N.N.N, Culture=neutral, PublicKeyToken=NNNNNNNNN' or one of its dependencies. The system cannot find the file specified.
Interestingly, in my custom Assembly Initializer code, I see XYZ.DLL being loaded from C:\InstallLocation. Is it possible this C++ module is attempting to load it differently or in a way that isn't supported by ASP.NET?
Whenever I try running unit tests in Visual Studio, I get the following warnings on a number of my tests, which cause them to fail:
Strong name verification failed for the instrumented assembly 'FULL
ASSEMBLY NAME REFERENCED IN WEB APP PROJECT'. Please ensure that the
right key file for re-signing after instrumentation is specified in
the test settings.`
Note that the FULL ASSEMBLY NAME REFERENCED IN WEB APP PROJECT is a library assembly that we are using from a third-party.
The interesting thing is the assembly warnings above appear in all tests that use FULL ASSEMBLY NAME REFERENCED IN WEB APP PROJECT, not just ones that are exercising the web app project. We reference this assembly in multiple projects.
I find that removing the web application from code coverage in my test settings file causes the test failures to go away...
How do I fix this?
Found a workaround:
I unchecked the ASP.NET webapp from code coverage in the testsettings, and then added the regular assembly for the webapp into code coverage.
All of the tests passed, and I was still able to get code coverage metrics from the webapp assembly.
Got some strange problem.
I'm developing some complicated Web Services network that uses some VB6 .dll. In my previous post I got some problems with the dll but we've solved them.
So, the new problem is:
When I debug my service (those which uses VB6 dll) on development server from visual studio - everything works fine, the problem starts when I publish my service on IIS (I tried my local IIS). After that, when I call .dll method (as I understand I need to call it by reference - and that's what the compiler tells me) I got an exception:
"System.Runtime.InteropServices.COMException (0x800A000D): Type mismatch at ..."
Actually is happens here in the third line:
Object s = (Object)OrderId;
Object s1 = (Object)lines.Length;
proxy.OrderRead(ref s, ref s1);
OrderId and Legth are integers.
As I understant this is exception that comes from the .dll from vb6 :/
What the problem may be? Why it runs when debugging but fails on IIS?
When debugging in vb6,the IDE will register the dll for you. After publishing, have you may ahve to register your vb6 dll on the server. Open a command prompt and change to the location of the dll and run regsvr32 myvb6.dll.
Also, check these settings.
http://support.microsoft.com/kb/281630
I have C++ project that compiles as DLL Assembly in .NET 3.5 SP1
Project is used for Image rendering processing by using WPF (it loads 2 images from local folder, applies one image on another and saves the output file in the same folder).
I want to use that that project as a reference in ASP.NET project to the rendering on the website.
So I created simple Web Project in ASP.NET C# that uses C++ project as a Reference.
Everything works great in ASP.NET Web Development Server (built-in Web server in VS2008).
But once I publish this project to IIS on the same Machine or use IIS for debug instead of built-in Web server Image rendering it's not working anymore. I'm not getting any exceptions or error messages, it just output image is not processes as it supposed to be.
If anyone know what could cause that I would really appreciate your insight!
Do you have access to the Event Logs? You should check there for any errors. You should try to throw an exception from a C#-only code path and make sure that everything is OK and regular exceptions are being thrown. Is the C++ compiled to managed code, or is native code? You might find that ASP.NET does not have the appropriate code access security permissions and needs to be registered in the GAC of the server to accessed from C#.
You should also check whether the DLL is thread-safe. This has caused issues for other users in ASP.NET/IIS.
I have a web application which references an external DLL (lets call this productA.dll)
I have updated my GAC, my web.config, and my references, checked the versions and everything looks consistent.
However, when I run my application, methods that I use from productA.dll cannot be called, and I get a the specified module cannot be found error.
I tried creating a windows application and I can use productA.dll perfectly fine.
Observing the output window during run-time for the web application, I noticed that productA.dll symbols are not loaded. So I'm guessing that is why the module cannot be found.
The question is: why are the symbols not being loaded?
Any tips on the solution or diagnostics techniques would be greatly appreciated.
It's not a requirement that the assembly be in the GAC. I'd say to check the following:
Your assembly is in the website's bin folder.
Your assembly is referenced in the assemblies section of the web.config.
The assembly reference in the web.config has the correct version number.
By the way, symbols will only be loaded if you have the debug file (.pdb) along side the assembly.