0
votes

Trying to add BouncyCastle c# dll to my WP8 native app.

  • I create a Windows Runtime Component for Windows Phone 8
  • I warp an existing C# dll in the component and create MyBouncyCastleComponent.winmd
  • I open my WP8 native project and I add the winmd as a reference

Result: At compile time "warning: No implementation file was provided for the .winmd file"

At runtime it crashes and when I stop the emulator I got "WinRT information: Class not registered" (its much longer than that, complaining about missing PDB file's in window files like Windows.winmd and System.Windows.RuntimeHost.ni.dll)

I opened the winmd with ILDASM. The implementations of decrypt and encrypt are there? What am I doing wrong?

MyBouncyCastleComponent.winmd opened with ildasm

I know its been asked No implementation file was provicded for the .winmd file but there is no answer yet. I'm trying again... (couldn't figure out how to add it as a question there)

EDIT:

Just a clarification. when I say: "I warp an existing C# dll in the component and create MyBouncyCastleComponent.winmd"
what I did was take BouncyCastle source code put it in the runtime component with a wrapper class to expose the BouncyCastle methods I needed.

1
No, the .winmd file only contains declarations, not the implementation. This is a packaging problem, for one, WinRT needs to know that the code is actually implemented in a language that requires the CLR to be loaded. That requires a manifest that contains the <clrClass> element. And the package needs to include the assembly. Whether the CLR on a phone even supports this is a bit of a long shot. - Hans Passant

1 Answers

0
votes

It very much looks like you're jumping through hoops to try and get a C# DLL compiled for the full .NET framework to work on Windows Phone. Windows Phone uses a different .NET profile and isn't binary compatible with the full .NET framework, so this cannot work.

For BouncyCastle you will need to reference a binary DLL built specifically for Windows Phone - for example by building one yourself from the BouncyCastle source code.

UPDATE: As you're using a subset of BouncyCastle you may be able to put the source code you need inside a Portable Class Library project so it can be directly used in both Windows Phone and Windows Store apps.