私はDLLを使ってC++ CLIを呼び出すC#プロジェクトを持っています。ボタンイベントのテキストボックスに表示される文字列をC#に返します。私はこのDLL(、MyDll.dllという名前)をC#プロジェクトプロパティの参照として追加して追加しました。私は、wixツールセットを使用してインストーラを作成しようとしています。ここにソースコードがあります。CLIプロジェクトのC#EXEがWIXインストーラでインストールされていません
C#コード
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyDll;
namespace MyProject
{
public partial class Form1 : Form
{
public Class1 obj = new Class1();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = "";
string str_new = obj.MyFunc(str);
textBox1.Text = str_new;
}
}
}
C++ CLIコード
#include "stdafx.h"
#include "MyDll.h"
namespace MyDll
{
Class1::Class1(){}
Class1::~Class1(){}
Class1::!Class1(){}
String^ Class1::MyFunc([Out] String^ str)
{
str = "My C++/Cli DLL";
return outVal = str;
}
}
C++ CLIヘッダー
// MyDll.h
#pragma once
using namespace System;
using namespace System::Runtime::InteropServices;
namespace MyDll {
public ref class Class1
{
// TODO: Add your methods for this class here.
public:
Class1::Class1();
Class1::~Class1();
Class1::!Class1();
String^ MyFunc([Out] String^ str);
String^ outVal;
};
}
私WXSは
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="installer_test" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="a928c48a-8e5b-4038-b871-939ff8a9349f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="installer_test" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Property Id="ROOTDRIVE">
<![CDATA[E:\]]>
</Property>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles" Name="ProgramFiles">
<Directory Id="TopFolder" Name="EXE3">
<Directory Id="INSTALLFOLDER" Name="Main folder">
<Component Id="cmpMain" Guid="{0509AAED-64A8-43F6-8935-70FB12305189}" KeyPath="yes" Feature="ProductFeature">
<File Source="$(var.MyProject.TargetPath)" />
<File Source="$(var.MyProject.TargetPath)" Name="MyDll.dll" ShortName="AF" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"></Property>
<UIRef Id="WixUI_InstallDir"/>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- <File Source="$(var.MyProject.TargetPath)"/>-->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
</Wix>
私のインストーラが正常に動作しますファイル。特定のパスにexeとdll(MyDll.dll)をインストールします。しかし、私はexeを実行すると、何もしません。私がインストールされたexeファイルを私のC#プロジェクトのbinフォルダに作成されるexeファイルに置き換えると、正常に動作します。どうすればこの問題を解決できますか? $(var.MyProject.TargetPath)
があなたのexeファイルであるならば、あなたはちょうどそれがMYDLL.DLL命名、1秒間に2回の時間を、それをインストールしている、
<File Source="$(var.MyProject.TargetPath)" />
<File Source="$(var.MyProject.TargetPath)" Name="MyDll.dll" ShortName="AF" />
:
おかげ