Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

I cannot debug my application

 
Post new topic   Reply to topic    Infralution Support Forum Index -> .NET Encryptor Support
View previous topic :: View next topic  
Author Message
Javier



Joined: 09 Oct 2009
Posts: 200

PostPosted: Sat Aug 16, 2014 10:45 am    Post subject: I cannot debug my application Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4884

PostPosted: Sat Aug 16, 2014 5:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 200

PostPosted: Sat Aug 16, 2014 7:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4884

PostPosted: Sat Aug 16, 2014 8:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 200

PostPosted: Sat Aug 16, 2014 8:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4884

PostPosted: Sun Aug 17, 2014 8:06 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 200

PostPosted: Sun Aug 17, 2014 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4884

PostPosted: Sun Aug 17, 2014 6:18 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 200

PostPosted: Sun Aug 17, 2014 6:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4884

PostPosted: Mon Aug 18, 2014 8:15 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 200

PostPosted: Mon Aug 18, 2014 12:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 4884

PostPosted: Mon Aug 18, 2014 4:52 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> .NET Encryptor Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group