При сборке dll ошибок нет, но она не работает.
При нажатии кнопки в программе должна появиться кнопка, появится сообщение "ТЕСТ".Но кнопка просто не появляется, несмотря на то, что во время сборки ничего не происходит.
Точно такой же код в C # работает, но необходим в cli.
Мой DllExport:
#pragma region Usings
#include "stdafx.h"
using namespace System;
using namespace System::Runtime::InteropServices;
#pragma endregion
namespace RGiesecke
{
namespace DllExport
{
/// <summary>
/// Used to control how to create an unmanaged export for a static method.
/// </summary>
/// <remarks>
/// You are not bound to using this class in this assembly.
/// By default, any attribute named "RGiesecke.DllExport.DllExportAttribute.DllExportAttribute" will do the trick.
/// Even if it is declared to be only visible inside the assembly with the static methods you want to export.
/// In such a case the naming and typing of the fileds/properties is critical or otherwise the provided values will not be used.
/// </remarks>
[AttributeUsage(AttributeTargets::Method, AllowMultiple = false)]
private ref class DllExportAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="DllExportAttribute"/> class.
/// </summary>
public:
DllExportAttribute()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DllExportAttribute"/> class.
/// </summary>
/// <param name="exportName">Name of the unmanaged export.
/// <seealso cref="ExportName"/></param>
DllExportAttribute(String ^exportName) //: DllExportAttribute(exportName, System::Runtime::InteropServices::CallingConvention::StdCall)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DllExportAttribute"/> class.
/// </summary>
/// <param name="exportName">Name of the unmanaged export.
/// <seealso cref="ExportName"/></param>
/// <param name="callingConvention">The calling convention of the unmanaged .
/// <seealso cref="CallingConvention"/></param>
DllExportAttribute(String ^exportName, System::Runtime::InteropServices::CallingConvention callingConvention)
{
ExportName = exportName;
CallingConvention = callingConvention;
}
private:
static System::Runtime::InteropServices::CallingConvention CConv = safe_cast< System::Runtime::InteropServices::CallingConvention>(0);
/// <summary>
/// Gets or sets the calling convention that will be used by the unmanaged export.
/// </summary>
/// <value>The calling convention.</value>
public:
property System::Runtime::InteropServices::CallingConvention CallingConvention
{
System::Runtime::InteropServices::CallingConvention get()
{
return CConv;
}
void set( System::Runtime::InteropServices::CallingConvention value)
{
CConv = value;
}
}
private:
String ^ExpName;
/// <summary>
/// Gets or sets the name of the unmanaged export.
/// </summary>
/// <value>The name of the export.</value>
public:
property String ^ExportName
{
String ^get()
{
return ExpName;
}
void set(String ^value)
{
ExpName = value;
}
}
};
}
}
Мой класс:
// ISHDAN.h
#pragma once
#include "DllExport\RGiesecke.DllExport.DllExportAttribute.h"
using namespace System::Windows::Forms;
using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace RGiesecke::DllExport;
namespace Class2 {
public ref class Class1
{
[DllExport("ISHDAN", CallingConvention = System::Runtime::InteropServices::CallingConvention::Cdecl)]
double static ISHDAN(String ^connTemp, String ^connEoi, String ^cex, String ^SV, String ^SO, String ^izd, String ^TP, String ^cher)
{
MessageBox::Show("TEST");
return 1;
}
};
}
Пожалуйста, вы можете посмотреть код и дать мне несколько подсказок?