c#和c+之间的链接+;在64位机器中 我在C++和C语言中编写了一个代码。从我的C++代码中,我通过调用我的C函数。我只发送了C++代码的一部分。
txtPath包含文本文件的位置。 C++代码:c#和c+之间的链接+;在64位机器中 我在C++和C语言中编写了一个代码。从我的C++代码中,我通过调用我的C函数。我只发送了C++代码的一部分。,c#,c++,com-interop,regasm,tlb,C#,C++,Com Interop,Regasm,Tlb,txtPath包含文本文件的位置。 C++代码: CoInitialize(NULL); IMyClassPtr obj3; obj3.CreateInstance(__uuidof(Program)); obj3->Validation(txtPath); CoUninitialize(); Validation()是我的c#函数。 我的c#代码: 我已经在c#中完成了所有必需的设置。C#project是一个类库。我的代码在32位机器上运行良好。
CoInitialize(NULL);
IMyClassPtr obj3;
obj3.CreateInstance(__uuidof(Program));
obj3->Validation(txtPath);
CoUninitialize();
Validation()是我的c#函数。
我的c#代码:
我已经在c#中完成了所有必需的设置。C#project是一个类库。我的代码在32位机器上运行良好。我在其他系统中使用生成的tlb,方法是将其注册到regasm.exe
< 64位机器由C++代码工作,但当C链接代码被击中时,执行停止,不会产生任何错误。我正在使用一台64位机器,并用相同的代码创建了一个新项目。请提供帮助在64位Windows上,Microsoft不支持将64位DLL加载到32位进程中,反之亦然。有关更多信息,请参阅MSDN上的以下资源:
确保您正在为目标平台使用正确版本的“regasm.exe”(即“C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm.exe”)。请注意“Framework64”。可以,但我现在使用的是64位机器。我用相同的代码在64位机器上创建了一个新项目。@jacobseleznev我的代码不起作用链接文章谈到64位Windows上的32位进程。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using word = Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ABC
{
[ComVisible(true)]
public interface IMyClass
{
void Validation(string txtp);
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class Program : IMyClass
{
private string replace_string(string text)
{
return text.Replace("\r\a", "");
}
public void Validation(string txtp)
{
string[] textValidate = File.ReadAllLines(txtp);
string textpath = txtp;
//validation starts here
foreach (string line in textValidate)
{
string[] strsplit = line.Split(new string[] { "," }, StringSplitOptions.None);
string task = strsplit[0];
string sign = strsplit[1];
string person = strsplit[2];
string routing = strsplit[3];
if (String.IsNullOrEmpty(task) || String.IsNullOrEmpty(sign) || String.IsNullOrEmpty(person))
{
//if the txt file is invalid
MessageBox.Show("Signature.txt is incomplete or has invalid input!!!");
}
}
}
}
}