View previous topic :: View next topic |
Author |
Message |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sat Aug 16, 2014 10:45 am Post subject: I cannot debug my application |
|
|
For some reason I cannot debug my application. When I place a breakpoint it says "The breakpoint will not currently be hit. No symbols have been loaded for this document". I googled this and I found dozens of related posts suggesting different approaches, but I haven't been able to make it work.
The only thing that I did was to set the configuration to Release and build the solution. Then I switched back to Debug and built the solution again, but now I cannot debug it. I believe it has to do with NET Encryptor because none of the assemblies has the symbols loaded, but the .exe file does. I did this exercise: Go to the bootstrap, press F5 to start the debugger, in VS select Debug | Windows | Modules. Under "Symbol Status" I see that the .exe says "Symbols loaded", but the individual assemblies say "No symbols loaded". Any idea would be appreciated. Thank you. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Aug 16, 2014 5:04 pm Post subject: |
|
|
Are you sure that your prebuild event in Visual Studio is encrypting the correct version of the exe based on the current configuration (Debug or Release). When swapping between Debug and Release you also need to do a rebuild of the solution (including your executable project) to force the encrypted file to be regenerated - otherwise .NET Encryptor may decide it does not need to rebuild the encrypted assembly file because it has a later date stamp than the exe. Alternatively you can delete the .enc encrypted file (from the Assemblies directory) to force it to be rebuilt. _________________ Infralution Support |
|
Back to top |
|
|
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sat Aug 16, 2014 7:43 pm Post subject: |
|
|
I'm confused now. The prebuild event is based on the Debug version. A typical line looks like this:
Code: | "C:\Program Files\Infralution\.NET Encryptor\bin\NetEncryptor.exe" "$(SolutionDir)Beam\bin\Debug\Beam.dll" /outdir:"$(ProjectDir)Assemblies" |
Do I need a prebuild event for the Release version as well? Or what is the correct version to use?
For example, now it is set to Debug configuration and the prebuild event is based on Debug as well, but I cannot debug the application. What could be the problem? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Aug 16, 2014 8:05 pm Post subject: |
|
|
The prebuild should probably be:
Code: | "C:\Program Files\Infralution\.NET Encryptor\bin\NetEncryptor.exe" "$(SolutionDir)Beam\bin\$(ConfigurationName)\Beam.dll" /outdir:"$(ProjectDir)Assemblies" |
That way the ConfigurationName variable is either Debug or Release depending on what is being built. That doesn't explain why you can debug given that you were hardcoding the use of the Debug version. It would however potentially have given you strange issues when building the Release version of your application - because you would actually have been including the Debug version of the application which may not have been up to date.
Right click on the Bootstrap project in your Visual Studio solution and click dependencies. Ensure that the Bootstrap is marked as depending on your application project. This will ensure that when you build the solution your application is built first and then the Bootstrap. Then use Rebuild All to rebuild the solution.
What version of Visual Studio are you using? What language (VB or C#)? _________________ Infralution Support |
|
Back to top |
|
|
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sat Aug 16, 2014 8:27 pm Post subject: |
|
|
I changed the prebuild event to include $(ConfigurationName). I set the dependencies and the Bootstrap is being built last. I rebuilt all in Debug and in Release. Same problem.
I use VS 2008, C#. Thank you. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sun Aug 17, 2014 8:06 am Post subject: |
|
|
If you want to debug then you need to Rebuild All in Debug before you run the application. DO NOT Rebuild All in Release after this. If you do then Visual Studio will build the release version of your application and the bootstrap prebuild event will encrypt it into your Assembly resources - which will then automatically get built into your debug version.
It is usually simpler just to run and debug your main application executable (rather than the bootstrap). This is because the bootstrap dynamically loads the assemblies and this can cause issues like what you are seeing if you haven't got everything exactly right. I would not normally bother debugging the Bootstrap unless I was encountering a problem that was not occurring when just running the normal (unencrypted) application. _________________ Infralution Support |
|
Back to top |
|
|
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sun Aug 17, 2014 12:00 pm Post subject: |
|
|
I rebuilt all in Debug several times and the problem persists.
Quote: | It is usually simpler just to run and debug your main application executable (rather than the bootstrap) |
I'm not trying to debug the bootstrap. How do you run and debug your main application, rather than the bootstrap? Is there a way to turn off the bootstrap during development? I'm a little confused about this concept. Thank you. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sun Aug 17, 2014 6:18 pm Post subject: |
|
|
You can select your application project in the Visual Studio Explorer pane and then select "Set as StartUp Project". The startup project is shown in bold in the explorer pane. Then when you debug it will start your application project instead of the bootstrap. Alternatively you can just create a separate solution that just contains your application project and any dependencies (and not the bootstrap project). _________________ Infralution Support |
|
Back to top |
|
|
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sun Aug 17, 2014 6:55 pm Post subject: |
|
|
Yes, this solved the issue.
In summary, I need to bypass the Bootstrap during development in Debug, and set my application project as Windows Application. Then when everything is debugged and ready to go, I need to change my application project back to Class Library and set the Bootstrap as the StartUp Project in Release.
Please confirm. Thank you. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Aug 18, 2014 8:15 am Post subject: |
|
|
You don't need to change the application project to a Class Library for use within the Bootstrap. The Bootstrap project can still load and execute your application assembly when the output is an exe. _________________ Infralution Support |
|
Back to top |
|
|
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Mon Aug 18, 2014 12:08 pm Post subject: |
|
|
But a Class Library (DLL) is more secure than a .exe, isn't it? If the application project is a DLL then the bootstrap is mandatory to make it work. If it's a .exe then the bootstrap could be bypassed. Please correct me if I'm wrong. Thank you. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Aug 18, 2014 4:52 pm Post subject: |
|
|
No there is no difference in security since both are encrypted and executed in the same way. You can't bypass the bootstrap because it is required to decrypt the assembly. _________________ Infralution Support |
|
Back to top |
|
|
|