PLEASE SEE UPDATE BELOW
I researched this to the end of the Internet, I find no real, understandable, human example of how to do this.
I have a C # DLL that encrypts and decrypts text.
I do not want / do not have the intellectual ability to rewrite this in C ++ unmanaged code. So instead, I created a C ++ / CLR class that interacts with the C # dll.
NOW I need to know how to call managed C ++ from my unmanaged code.
Here is my managed code and it is verified that it works
#include "cSharpRiJHarn"
#include "stdafx.h"
#include <string>
#include <stdio.h>
using namespace cSharpRiJHarn;
using namespace System;
String^ Encrypt(String ^s)
{
return RijndaelLink::encrypt(s);
}
String^ Decrypt(String ^s)
{
return RijndaelLink::decrpyt(s);
}
int main()
{
return 0;
}
Now, once again, I explored this.
I saw all the erroneous / overly complex explanations
, - COM Interop
, , .
.
UPDATE
DLL # COM
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cSharpRiJHarn
{
[Guid("GuiD CODE REMOVED")]
public interface DBCOM_Interface
{
[DispId(1)]
String encrypt(string s);
[DispId(2)]
String decrpyt(string s);
}
[Guid("GuiD CODE REMOVED"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface DBCOM_Events
{
}
[Guid("GuiD CODE REMOVED"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(DBCOM_Events))]
public class RijndaelLink : DBCOM_Interface
{
public String encrypt(String s)
{
return Rijndael.EncryptString(s);
}
public String decrpyt(String s)
{
return Rijndael.DecryptString(s);
}
}
}
, ++...
++, cSharpRiJHarn . .
#import "cSharpRiJHarn"
#include "stdafx.h"
#include <string>
#include <stdio.h>
#include <iostream>
int main(){
cSharpRiJHarn::RijndaelLink::encrypt("It works");
char ch;
std::cin>>ch;
return 0;
}
, .
6 C2653: 'cSharpRiJHarn':
8 IntelliSense: "C:/.../...//Visual Studio 2010//unmannagedCPPExample/unmannagedCPPExample/Debug/cSharpRiJHarn.tlh" c:......\documents\visual 2010\Projects\unmannagedcppexample\unmannagedcppexample\unmannagedcppexample.cpp