0

To start, I know this question has been asked a million times all over the place, but as I have no experience with VB/Visual Studio, I can't find a solution that I can make sense of.

I am creating a new VB.net project(solution?), and am making calls to functions from a C library that are in a dll file. The dll file does have a pdb file and they are both stored at the same location.

In the code below it shows how I declare the functions in my VB.net code, but I have not figured out how to attach the pdb file to the project.

Declare Function InitRelay Lib "Z:\Devel\RelayAPI\Debug\RelayAPI.dll" (ByVal setbaud As Action(Of Short), ByVal getit As Func(Of Short, Short), ByVal putit As Action(Of Short), ByVal flushit As Action, ByVal delay As Action(Of Short)) As Byte
Declare Sub FreeRelay Lib "Z:\Devel\RelayAPI\Debug\RelayAPI.dll" ()
...

I am getting an exception somewhere in the DLL file, but the way I have it set up, I can not debug the dll file. Whether its adding breakpoints, or print statements, I need a way to see where in the dll the project fails.

Questions I have looked at:

  • How to debug a referenced dll - I tried following the menu path given in the accepted answer, but when I go to Project >> Project Properties I see no Build option. It also says I can load symbols directly in the IDE if I don't want to copy any files, but I cannot find an explanation on how to do it. EDIT - As Plutonix says below, C# Build is the equivalent of VB's Compile tab. I checked and my Debug Info is set to Full, so this does not solve my problem.
  • Debugging a third-party DLL in Visual Studio? - This talks about a DLL in a .NET language but mine is in C. It also only tells you how to view the code, which I already can do. I have access to the .c and .h files that are used to create the dll, I just cannot debug them at runtime.
Community
  • 1
  • 1
JuiCe
  • 4,132
  • 16
  • 68
  • 119
  • The properties tabs are different in VB vs C#. C# has a Build Tab in place of VB's Compile. In what do you edit/build the C project? – Ňɏssa Pøngjǣrdenlarp Jun 24 '14 at 15:22
  • Thanks for the info, but didn't solve the problem. I just checked my `Compile Options` and the option is already set to `All`. – JuiCe Jun 24 '14 at 15:25
  • to step into the C DLL, assuming the symbols are available, enable unmanaged debugging (Project Props -> Debug -> Check `Enable Unmanaged Debugging` then also be sure to disable Just my code (Tools -> Options -> Debug General -> uncheck `Enable just my code` (note the names may change a little version to version - this is for VS2012) – Ňɏssa Pøngjǣrdenlarp Jun 24 '14 at 15:42
  • It doesn't have `Enable Unmanaged Debugging`, so I checked `Enable native code debugging.` This gave me a new error, telling me it can't find the PDB file. Can I just drag the PDB file into the project folder? It is already located at the same path as the `.dll` file, which I show in the code given in the question. – JuiCe Jun 24 '14 at 15:55
  • you might be able to manually load the symbols via Options -> Debug -> Symbols ...or... the default is to copy referenced files to the \Bin\ folder; you could place a copy there (its where VS copies any PDB for other managed projects). it USED to be called `Enable Unmanaged Debugging`, sorry – Ňɏssa Pøngjǣrdenlarp Jun 24 '14 at 16:02

1 Answers1

-1

When you debug a DLL, you can start debugging from: The project used to create the executable that calls the DLL. - or - The project used to create the DLL itself.

There are a couple of ways to debug a reference DLL file using VS 2013, so here the method Microsoft uses

-->To specify an executable for the debug session

  1. In Solution Explorer, select the project that creates the DLL.
  2. From the View menu, choose Property Pages.
  3. In the Property Pages dialog box, open the Configuration Properties folder and select the Debugging category.
  4. In the Command box, specify the path name for the container. For example, C:\Program Files\MyApplication\MYAPP.EXE.
  5. In the Command Arguments box, specify any necessary arguments for the executable.

Here I included 2 different methods for debugging a DLL file directly from Microsoft.

1> http://msdn.microsoft.com/en-us/library/605a12zt.aspx (Native Mode)

2> http://msdn.microsoft.com/en-us/library/kbaht4dh.aspx (Mixed Mode)

If this was anyhelp to you or solved your problem please make sure to drop a "vote up"

Ref. All information is from personal experience and Microsoft

AH Tek
  • 24
  • 1
  • I have read the MSDN page multiple times. If you read the question I asked, this doesn't answer it. For future reference, rewording the first result you get on google into your answer isn't the proper way to answer a question. – JuiCe Jun 24 '14 at 20:22
  • Google Result converted into stackoverflow answer, hmmm not smart enough. – Suhail Mumtaz Awan Jan 29 '16 at 11:03