链接混合模式和托管程序集 [英] Linking Mixed Mode and Managed Assemblies

查看:80
本文介绍了链接混合模式和托管程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个托管C ++项目和两个C#项目。所有都是班级图书馆

项目。 C ++项目链接到本机C ++静态库和

引用一个C#项目。项目结构是这样的。


Proj2_MCPP - (参考) - Proj1_CSharp

Proj3_CSharp - (参考) - Proj2_MCPP和Proj1_CSharp


我的目标是将3个项目生成的DLL链接到一个DLL中。


我尝试了以下场景。

1. csc Proj1_CSharp进入netmodule

2. cl Proj2_MCPP with / LN和/ clr:oldSyntax切换生成.obj文件

3. csc Proj3_CSharp with / AddModule选项并使用.netmodule和.obj文件

作为输入

4.将1,2和3链接到一个dll。


和我也尝试了这个。

1. csc Proj1_CSharp到netmodule

2.从VS.NET 2005构建Proj2_MCPP(基于
http://support.microsoft.com/kb/309805 )生成.netmodule和obj .files。

3.使用/ AddModule选项的csc Proj3_CSharp并使用.netmodule和.o bj文件

作为输入

4.将1,2和3链接到一个dll。


我从未设法达到步骤4.我只是坚持在第3步产生错误消息




我做对了吗?或者这是不可能的?


谢谢 - 亨利

I have a managed C++ project and two C# projects. All are class library
projects. The C++ project links with native C++ static libraries and
references to one C# project. The projects structure goes something like this.

Proj2_MCPP --(references)--Proj1_CSharp
Proj3_CSharp --(references)--Proj2_MCPP and Proj1_CSharp

My objective is to link the DLLs produced by the 3 projects into a single DLL.

I tried the following scenario.
1. csc Proj1_CSharp into a netmodule
2. cl Proj2_MCPP with /LN and /clr:oldSyntax switch to produce .obj files
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.

and I also tried this.
1. csc Proj1_CSharp into a netmodule
2. Build Proj2_MCPP from VS.NET 2005 (based on
http://support.microsoft.com/kb/309805) to produce .netmodule and obj .files.
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.

I never managed to reach step 4. I just stuck with error messages resulted
from step 3.

Am I doing the right thing? Or it is just not possible?

Thanks - Henry

推荐答案

类库项目是DLL。你不能直接将DLL链接到一个新的DLL中。


您可以尝试一个名为ILMerge的实用程序[1];但是我还没试过

混合模式的DLL。


[1] http://research.microsoft.com/~mbarnett/ILMerge.aspx


-

浏览 http:// connect。 microsoft.com/VisualStudio/feedback/ 并投票。
http: //www.peterRitchie.com/blog/

Microsoft MVP,Visual Developer - Visual C#

" ignhenry"写道:
Class library projects are DLLs. You can''t directly link DLLs together into
a new DLL.

You could try a utility called ILMerge [1]; but I haven''t tried it with
mixed-mode DLLs.

[1] http://research.microsoft.com/~mbarnett/ILMerge.aspx

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"ignhenry" wrote:

我有一个托管C ++项目和两个C#项目。所有都是班级图书馆

项目。 C ++项目链接到本机C ++静态库和

引用一个C#项目。项目结构是这样的。


Proj2_MCPP - (参考) - Proj1_CSharp

Proj3_CSharp - (参考) - Proj2_MCPP和Proj1_CSharp


我的目标是将3个项目生成的DLL链接到一个DLL中。


我尝试了以下场景。

1. csc Proj1_CSharp进入netmodule

2. cl Proj2_MCPP with / LN和/ clr:oldSyntax切换生成.obj文件

3. csc Proj3_CSharp with / AddModule选项并使用.netmodule和.obj文件

作为输入

4.将1,2和3链接到一个dll。


和我也尝试了这个。

1. csc Proj1_CSharp到netmodule

2.从VS.NET 2005构建Proj2_MCPP(基于
http://support.microsoft.com/kb/309805 )生成.netmodule和obj .files。

3.使用/ AddModule选项的csc Proj3_CSharp并使用.netmodule和.obj f iles

作为输入

4.将1,2和3链接到一个dll。


我从未设法达到第4步我只是坚持了第3步产生的错误消息




我做对了吗?或者这是不可能的?


谢谢 - 亨利
I have a managed C++ project and two C# projects. All are class library
projects. The C++ project links with native C++ static libraries and
references to one C# project. The projects structure goes something like this.

Proj2_MCPP --(references)--Proj1_CSharp
Proj3_CSharp --(references)--Proj2_MCPP and Proj1_CSharp

My objective is to link the DLLs produced by the 3 projects into a single DLL.

I tried the following scenario.
1. csc Proj1_CSharp into a netmodule
2. cl Proj2_MCPP with /LN and /clr:oldSyntax switch to produce .obj files
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.

and I also tried this.
1. csc Proj1_CSharp into a netmodule
2. Build Proj2_MCPP from VS.NET 2005 (based on
http://support.microsoft.com/kb/309805) to produce .netmodule and obj .files.
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.

I never managed to reach step 4. I just stuck with error messages resulted
from step 3.

Am I doing the right thing? Or it is just not possible?

Thanks - Henry


谢谢,彼得。我在某处读过ILMerge和Al.exe只适用于纯粹的b $ b托管程序集,但是不支持包含托管的

和非托管代码的混合模式DLL。我把它们从我的列表中删除了。


现在我正在考虑使用CSharp编译器和VC ++链接器。我在互联网新闻组中看到了

,有些人让它成功运作。我的CSharp

编译器抱怨某些类被多次定义。

显然,我仍然遗漏了一些东西 - 可能很简单。


- Henry


" Peter Ritchie [C#MVP]"写道:
Thanks, Peter. I read somewhere that ILMerge, and Al.exe, only work for pure
managed assemblies, but don''t support mixed mode DLLs containing both managed
and unmanaged code. I dropped them from my list.

Right now I am looking at using CSharp compiler and VC++ linker. I''ve seen
in internet newsgroups some people got it working successfully. My CSharp
compiler is complaining that some classes are defined multiple times.
Obviously, I am still missing something - probably simple.

-- Henry

"Peter Ritchie [C# MVP]" wrote:

类库项目是DLL。你不能直接将DLL链接到一个新的DLL中。


您可以尝试一个名为ILMerge的实用程序[1];但是我还没试过

混合模式的DLL。


[1] http://research.microsoft.com/~mbarnett/ILMerge.aspx


-

浏览 http:// connect。 microsoft.com/VisualStudio/feedback/ 并投票。
http: //www.peterRitchie.com/blog/

Microsoft MVP,Visual Developer - Visual C#


" ignhenry"写道:
Class library projects are DLLs. You can''t directly link DLLs together into
a new DLL.

You could try a utility called ILMerge [1]; but I haven''t tried it with
mixed-mode DLLs.

[1] http://research.microsoft.com/~mbarnett/ILMerge.aspx

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"ignhenry" wrote:

我有一个托管C ++项目和两个C#项目。所有都是班级图书馆

项目。 C ++项目链接到本机C ++静态库和

引用一个C#项目。项目结构是这样的。


Proj2_MCPP - (参考) - Proj1_CSharp

Proj3_CSharp - (参考) - Proj2_MCPP和Proj1_CSharp


我的目标是将3个项目生成的DLL链接到一个DLL中。


我尝试了以下场景。

1. csc Proj1_CSharp进入netmodule

2. cl Proj2_MCPP with / LN和/ clr:oldSyntax切换生成.obj文件

3. csc Proj3_CSharp with / AddModule选项并使用.netmodule和.obj文件

作为输入

4.将1,2和3链接到一个dll。


和我也尝试了这个。

1. csc Proj1_CSharp到netmodule

2.从VS.NET 2005构建Proj2_MCPP(基于
http://support.microsoft.com/kb/309805 )生成.netmodule和obj .files。

3.使用/ AddModule选项的csc Proj3_CSharp并使用.net模块和.obj文件

作为输入

4.将1,2和3链接到一个dll。


我从未管理过到达第4步。我只是坚持产生错误消息

来自第3步。


我做对了吗?或者这是不可能的?


谢谢 - 亨利
I have a managed C++ project and two C# projects. All are class library
projects. The C++ project links with native C++ static libraries and
references to one C# project. The projects structure goes something like this.

Proj2_MCPP --(references)--Proj1_CSharp
Proj3_CSharp --(references)--Proj2_MCPP and Proj1_CSharp

My objective is to link the DLLs produced by the 3 projects into a single DLL.

I tried the following scenario.
1. csc Proj1_CSharp into a netmodule
2. cl Proj2_MCPP with /LN and /clr:oldSyntax switch to produce .obj files
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.

and I also tried this.
1. csc Proj1_CSharp into a netmodule
2. Build Proj2_MCPP from VS.NET 2005 (based on
http://support.microsoft.com/kb/309805) to produce .netmodule and obj .files.
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.

I never managed to reach step 4. I just stuck with error messages resulted
from step 3.

Am I doing the right thing? Or it is just not possible?

Thanks - Henry


Visual Studio没有'' t支持它们,但编译成netmodules然后可以使用Assembly Linker(al.exe)作为程序集连接在一起。


我不是确定如何让c ++编译器生成netmodules ...


-

浏览 http://connect.microsoft.com/VisualStudio/feedback/ 并投票。
http://www.peterRitchie.com/blog/

Microsoft MVP,Visual Developer - Visual C#

" ignhenry"写道:
Visual Studio doesn''t support them, but compiling to netmodules could then be
linked together as an assembly using Assembly Linker (al.exe).

I''m not sure how to get c++ compiler to generate netmodules...

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"ignhenry" wrote:

谢谢,彼得。我在某处读过ILMerge和Al.exe只适用于纯粹的b $ b托管程序集,但是不支持包含托管的

和非托管代码的混合模式DLL。我把它们从我的列表中删除了。


现在我正在考虑使用CSharp编译器和VC ++链接器。我在互联网新闻组中看到了

,有些人让它成功运作。我的CSharp

编译器抱怨某些类被多次定义。

显然,我仍然遗漏了一些东西 - 可能很简单。


- Henry


" Peter Ritchie [C#MVP]"写道:
Thanks, Peter. I read somewhere that ILMerge, and Al.exe, only work for pure
managed assemblies, but don''t support mixed mode DLLs containing both managed
and unmanaged code. I dropped them from my list.

Right now I am looking at using CSharp compiler and VC++ linker. I''ve seen
in internet newsgroups some people got it working successfully. My CSharp
compiler is complaining that some classes are defined multiple times.
Obviously, I am still missing something - probably simple.

-- Henry

"Peter Ritchie [C# MVP]" wrote:

类库项目是DLL。你不能直接将DLL链接到一个新的DLL中。


您可以尝试一个名为ILMerge的实用程序[1];但是我还没试过

混合模式的DLL。


[1] http://research.microsoft.com/~mbarnett/ILMerge.aspx


-

浏览 http:// connect。 microsoft.com/VisualStudio/feedback/ 并投票。
http: //www.peterRitchie.com/blog/

Microsoft MVP,Visual Developer - Visual C#

" ignhenry"写道:
Class library projects are DLLs. You can''t directly link DLLs together into
a new DLL.

You could try a utility called ILMerge [1]; but I haven''t tried it with
mixed-mode DLLs.

[1] http://research.microsoft.com/~mbarnett/ILMerge.aspx

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"ignhenry" wrote:

我有一个托管C ++项目和两个C#项目。所有都是班级图书馆

项目。 C ++项目链接到本机C ++静态库和

引用一个C#项目。项目结构是这样的。

>

Proj2_MCPP - (参考) - Proj1_CSharp

Proj3_CSharp - (参考) - -Proj2_MCPP和Proj1_CSharp

>

我的目标是将3个项目生成的DLL链接到一个DLL中。

>

我尝试了以下场景。

1. csc Proj1_CSharp到netmodule

2. cl Proj2_MCPP with / LN和/ clr:oldSyntax切换到生成.obj文件

3. csc Proj3_CSharp带/ AddModule选项并使用.netmodule和.obj文件

作为输入

4.链接1 ,2和3进入一个dll。

>

我也尝试了这个。

1. csc Proj1_CSharp进入netmodule

2.从VS.NET 2005构建Proj2_MCPP(基于
http://support.microsoft.com/kb/309805 )生成.netmodule和obj。文件。

3. csc Proj3_CS用/ AddModule选项竖琴并使用.netmodule和.obj文件

作为输入

4.将1,2和3链接到一个dll。

>

我从未设法进入第4步。我只是坚持使用错误信息产生了

来自第3步。

>

我做对了吗?或者这是不可能的?

>

谢谢 - 亨利
I have a managed C++ project and two C# projects. All are class library
projects. The C++ project links with native C++ static libraries and
references to one C# project. The projects structure goes something like this.
>
Proj2_MCPP --(references)--Proj1_CSharp
Proj3_CSharp --(references)--Proj2_MCPP and Proj1_CSharp
>
My objective is to link the DLLs produced by the 3 projects into a single DLL.
>
I tried the following scenario.
1. csc Proj1_CSharp into a netmodule
2. cl Proj2_MCPP with /LN and /clr:oldSyntax switch to produce .obj files
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.
>
and I also tried this.
1. csc Proj1_CSharp into a netmodule
2. Build Proj2_MCPP from VS.NET 2005 (based on
http://support.microsoft.com/kb/309805) to produce .netmodule and obj .files.
3. csc Proj3_CSharp with /AddModule option and use .netmodule and .obj files
as input
4. Link 1, 2 and 3 into a dll.
>
I never managed to reach step 4. I just stuck with error messages resulted
from step 3.
>
Am I doing the right thing? Or it is just not possible?
>
Thanks - Henry


这篇关于链接混合模式和托管程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆