Coder6841
Coder6841

Reputation: 1211

How can I remotely debug a C# .NET 4.5 WinForms application on a Raspberry Pi 3 using Visual Studio 2015?

I am attempting to remotely debug a C# .NET 4.5 WinForms application on a Raspberry Pi 3 (running Raspbian Jessie) using Visual Studio 2015 on a Windows machine.

As I understand it, I can use MonoRemoteDebugger for this. I've installed the Visual Studio extension and run the server program on the Pi but when I attempt to debug the application the MonoRemoteDebugger.Server.exe program displays an error which comes from the pdb2mdb.exe program. Here is the error:

Fatal error: Microsoft.Cci.Pdb.PdbDebugException: Unknown custom metadata item kind: 6 at Microsoft.Cci.Pdb.PdbFunction.ReadCustomMetadata (Microsoft.Cci.Pdb.BitAccess bits) [0x00000] in :0
at Microsoft.Cci.Pdb.PdbFunction..ctor (System.String module, ManProcSym proc, Microsoft.Cci.Pdb.BitAccess bits) [0x00000] in :0 at Microsoft.Cci.Pdb.PdbFunction.LoadManagedFunctions (System.String module, Microsoft.Cci.Pdb.BitAccess bits, UInt32 limit, Boolean readStrings) [0x00000] in :0 at Microsoft.Cci.Pdb.PdbFile.LoadFuncsFromDbiModule (Microsoft.Cci.Pdb.BitAccess bits, Microsoft.Cci.Pdb.DbiModuleInfo info, Microsoft.Cci.Pdb.IntHashTable names, System.Collections.ArrayList funcList, Boolean readStrings, Microsoft.Cci.Pdb.MsfDirectory dir, System.Collections.Generic.Dictionary`2 nameIndex, Microsoft.Cci.Pdb.PdbReader reader) [0x00000] in :0 at Microsoft.Cci.Pdb.PdbFile.LoadFunctions (System.IO.Stream read, Microsoft.Cci.Pdb.BitAccess bits, Boolean readAllStrings) [0x00000] in :0 at Microsoft.Cci.Pdb.PdbFile.LoadFunctions (System.IO.Stream read, Boolean readAllStrings) [0x00000] in :0 at Pdb2Mdb.Driver.Convert (Mono.Cecil.AssemblyDefinition assembly, System.IO.Stream pdb, Mono.CompilerServices.SymbolWriter.MonoSymbolWriter mdb) [0x00000] in :0

I've tried running the command "pdb2mdb MyProgram.exe" on the Pi and it produces the same error so it appears that the issue is with the pdb2mdb.exe program. With some digging I found that it appears that this was a bug in Mono.Cecil which was fixed in version 0.9.6 but it seems like the latest version available for Raspian Jessie is 0.9.5.

I've tried just replacing pdb2mdb.exe with the one from here and the error then changes to:

Unhandled Exception: System.TypeLoadException: Could not load type 'Mono.Cecil.AssemblyDefinition' from assembly 'pdb2mdb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'Mono.Cecil.AssemblyDefinition' from assembly 'pdb2mdb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Is the solution to try to get a newer Mono.Cecil version on the Pi? If so, how would I go about that, as well as ensure that pdb2mdb.exe references the newer version?

Upvotes: 0

Views: 1103

Answers (1)

Coder6841
Coder6841

Reputation: 1211

I've resolved the problem!

The first issue was with pdb2mdb.exe. The wheezy package source from mono-project.com had to be used to get the latest mono packages using these commands:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-complete mono-devel

After that, MonoRemoteDebugger in Visual Studio was displaying the following error:

Unable to start program 'C:\Test1\Test1.exe'.

The located assembly's manifest definition does not match the assembly reference.

To work around this I removed the MonoRemoteDebugger 1.0.5 Visual Studio extension and installed version 1.0.4 which doesn't have this problem.

Upvotes: 1

Related Questions