简体   繁体   中英

Problem with built assembly not matching source when debugging under IIS 7.5

I have a problem debugging a web forms application that is configured to use IIS for debugging, under Windows 7 and Visual Studio 2010. An example has just occurred, where I make a change to the code behind for a web form, save, and apparently rebuild before starting the app using F5.

The app starts, and I get an error message trying to do something in the app. I tell the debugger to break when an exception is thrown and try my task again, only to be told

The source file is different from when the module was built.

where the module is C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\Temporary ASP.NET Files\\root\\9d7b45ca\\11a98b19\\assembly\\dl3\\5e6cf0b2\\636409d4_dfeecb01\\PerfixEMS_Admin.DLL

The physical folder for my test web site is set to the web application project's source folder, so I have always assumed that IIS will look in the bin folder for required assemblies, and these will be rebuilt as expected. Why is this not happening?

Cleaning the solution usually works for me.

Update

Given the high number (320) of projects I understand why Clean and Build won't work for you. You should however try it at least once to see if fixes things.

If it does fix your problem but doesn't last you'll need to do one of two things.

Clean just the one file

Delete the offending temp file. You probably won't be able to do this because with VS running since it may have a lock on the DLL. You may also have to stop IIS. You can use Process Explorer to look for the processes that have a lock.

Use a custom solution

Its unlikely that you're going to be modifing all 320 projects at the same time. Create a custom solution for just the projects you're working on. You'll still be able to step through any project you have the DLL and PDB for if you need to.


Which to do

Using a custom solution has its problems since you can no longer use project reference for projects not in your solution. This impacts your team's source control. You'll also have to make sure the DLL's and PDB's from outside your solution are in a stable location and you'll need a way to detect when thoes other projects have changes that you care about.

These problems can be overcome with a careful check-in process for Project changes and scripts that copy files and working with team members to figure out how to communicate changes.

On the other hand closing VS for every change or running Clean and build isn't really tennable either.

it may be a workaround, but I just need to see if it will work or not, then we may investigate more in the original case. but for now, try this:

1- publish this website to a different folder

2- open the newly published version from your preferred browser (ex: http://localhost/APP_NAME ).

3- from VS, open "Debug" menu, choose "Attach to process..."

4- select the IIS worker process "w3wp.exe" and click "Attach".

( if you can't find it, make sure that the checkbox "show processes in all sessions" is checked )

5- start debugging your source code normally and let me know what happened, thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM