1

I've spent every day this week trying to find information about this problem I'm encountering when trying to debug an ASP.NET application. I've looked in the source file is different from when the module was built and Getting “The source file is different from when the module was built.” for help with this and haven't gotten anywhere.

I have a solution containing one project with a DLL reference to a library produced from another project within a different solution that contains many different projects.

My web app uses the source code from the first project, so I'm attaching the debugger to it and running the web app with breakpoints set up in the code.

While using the app I try to step into code from the DLL that is referenced and it tells me that 'The source file is different from when the module was built.'

I've tried deleting the bin and obj folders from both solutions and rebuilding the dlls then removed and re-added the reference to the dll within the first project. I don't understand why it would tell me the source file is different from when the module was built when I JUST built it and added the reference.

I think there is something simple that I'm overlooking but i don't know what else to try. Has anyone else fixed a situation like this before?

Edit: I've just tried to attach the source code from the project that actually builds the DLL that I'm using, and even that does not line up correctly with where the debugger stops in my code. I can't seem to find a way to look up the location of the DLL that is being used by the debugger, but it certainly is not the one I'm building.

Edit 2: I've managed to find out that there was a copy of the old DLL in "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files" which I deleted, but every time I would run the application it would re-create that folder and file structure exactly how it was before. So I've made a batch file I run every time I compile my project that copies over the new DLL to the DNN bin folder in the meantime.

Community
  • 1
  • 1
Zack
  • 2,789
  • 33
  • 60
  • Any chance this is a duplicate of this post: http://stackoverflow.com/questions/353421/getting-the-source-file-is-different-from-when-the-module-was-built ? – Jon Peterson Dec 26 '12 at 22:38
  • 1
    @JonPeterson Did you notice I linked to that question myself, and that I've stated that I already checked that question for a solution. – Zack Dec 26 '12 at 22:55
  • Does this DLL contain the data base access code? – Flot2011 Dec 27 '12 at 15:45
  • @Flot2011 I believe it may. I creates a connection to the DB at the least. – Zack Dec 27 '12 at 17:43
  • Have you double checked that the virtual directory in IIS really points to the place where you are building your code? E.g., is your virtual directory pointing to C:\inetpub\wwwroot\myapp, but your project now lives in C:\development\myapp? – aquinas Dec 27 '12 at 18:05
  • @aquinas Yes I'm sure it is pointing to the correct place. I've never moved the website, only built DLL files and replaced the ones in the DNN bin folder with the updated versions. I'm actually starting to think that this was was simpler than I thought. I set up in my batch file to copy the DLL from the bin folder of the project, to the bin of my DNN install, and I can now step through the code perfectly fine. I'm thinking that maybe all along all I had to do was copy that file, and IIS was pulling the DLL it used from the DNN bin.. which makes sense to me now that I actually think of it. – Zack Dec 27 '12 at 18:16

2 Answers2

3

Are you using iis or the integrated web dev server? Just guessing here, but your web server might Be still using an old copy of your dll, so try restarting it after you rebuild your projects.

I dont have access to VS at the moment, but if I recall correctly, when you hit the run button in vs the output window contains the path to all loaded dlls. Check there to see if you are indeed loading the correct module.

Hope this helps

Edit: also, remember to copy the pdb file! Since you are referencing a dll, it is very likely that the pdb file for that dll in the bin folder is out of sync with the version you just built.

corrego
  • 327
  • 1
  • 7
  • I'm using IIS to host, with DotNetNuke as my CMS. So I'm not running it directly from VS, I'm browsing to the website from IIS. I'll see if it still loads the paths like you mentioned when I attach to the worker process. – Zack Dec 27 '12 at 14:32
  • I think I should mark your post as the answer. Your bit about the currently loaded DLLs within VS made me find this answer http://stackoverflow.com/a/3454411/1804496. And I was able to see exactly where the DLL was being loaded from. Thank you for your help! – Zack Dec 27 '12 at 18:24
0

I think I figured out why IIS and VS were using an old version of the DLL. It was because I still had an old version in the DotNetNuke bin folder. Once I actually copied the new DLL from building the projects to the DNN bin I've been able to step through code fine. I never thought to actually check there for some reason.

Zack
  • 2,789
  • 33
  • 60
  • This cleared it up http://msdn.microsoft.com/en-us/library/ms366723.aspx ASP.net was getting the DLLs from my DotNetNuke bin folder, which I didn't check – Zack Dec 27 '12 at 19:53