Как вызвать управляемую DLL из собственного кода Visual C ++ в Visual Studio 2008

Я нашел статью под названием
Как вызвать управляемую DLL из собственного кода Visual C ++ в Visual Studio.NET или в Visual Studio 2005
Это было рекомендовано мне коллегой, потому что я нашел полезную библиотеку C #, которая потребовала бы довольно большой работы для переноса на C ++ (я оцениваю 2-3 недели).

Статья здесь: http://support.microsoft.com/kb/828736/en-us
Я все еще пытаюсь создать часть, которая экспортирует функцию из C #, чтобы я мог вызвать ее из
C ++
Весь код main.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//Interface declaration
public interface ICalculator
{
int Add(int Number1, int Number2);
};

//Interface Implementationpublic class ManagedClass:ICalculator
{
public int Add(int Number1, int Number2)
{
return Number1 + Number2;
}
}

Assemblyinfo.cs это

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("sManagedDLL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("sManagedDLL")]
[assembly: AssemblyCopyright("Copyright ©  2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components.  If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5a30f24d-c60b-49fe-9943-afe862741030")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyDelaySign(false)]

к сожалению, кажется, что есть хотя бы одна ошибка: проект sManagedDLL внезапно теряет свои начальные «s» при вызове regasm.exe.

Я работаю с VS 2008 и Windows 7 на 64-битной машине.

Когда я попытался вызвать regasm.exe, я получил сообщение, что не могу найти sManagedDLL.dll или одну из его зависимостей. Поэтому я запустил средство проверки зависимостей, чтобы посмотреть на созданную DLL. Я получил следующие сообщения об ошибках

Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

У вас есть какие-нибудь предложения?

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector