有谁装了Visual Studio.NET 2003吗?我有个问题!

pzhou 2003-06-02 04:05:42
怎么Visual Studio.NET 2003不能建托管的工程了。

我新建了一个工程,工程名test(我想用VC++.NET写一个类库在C#中引用。)

文件-〉新建-〉项目-〉Visual C++项目-〉.NET-〉(类库).NET

可是我在新建好的项目中使用这么一条语句
char* pTemp = new char[20];
都无法连接通过(编译通过了),以下是错误信息:

正在链接...
test.obj : error LNK2001: 无法解析的外部符号 "void * __cdecl operator
new(unsigned int)" (??2@$$FYAPAXI@Z)
D:\Visual Studio Projects\test\Debug\test.dll : fatal error LNK1120: 1 个无法解析的外部命令

另外,我要是在代码中使用strcpy,strcat,memset等函数,并且包含了string.h,memory.h等头文件,也会出现类似的连接错误。

VC++.NET 2002建立托管的类库好像就不会这样,我把VC++.NET 2002建的工程升级到VC++.NET 2003的工程就不会出现这样的问题。

有没有知道这是怎么回事的高手!希望赐教!


// test.h

#pragma once

using namespace System;

namespace test
{
public __gc class Class1
{
// TODO: 在此添加此类的方法。
public:

int test(void)
{
char * pTemp = new char[20];
return 0;
}
};
}


...全文
66 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pzhou 2003-06-18
  • 打赏
  • 举报
回复
从msdn里找到的

To convert the managed DLL to mixed mode

1.Link with /NOENTRY. In Solution Explorer, right-click the project node and click Properties. In the project's Property Pages dialog box, click Linker, and then click Command Line. Add this switch to the Additional Options field.

2.Link msvcrt.lib. In the project's Property Pages dialog box, click Linker, and then click Input. Add msvcrt.lib to the Additional Dependencies property.

3.Remove nochkclr.obj. On the Input page (same page as previous step), remove nochkclr.obj from the Additional Dependencies property.

4.Link in the CRT. On the Input page (same page as previous step), add __DllMainCRTStartup@12 to the Force Symbol References property.
alornwolf 2003-06-18
  • 打赏
  • 举报
回复
我昨天也刚装了VC.NET2003,打开我以前用vs.net2002的程序,vc.net的,编译也不能通过,也不知它倒义作了哪些改变!
xhan2000 2003-06-02
  • 打赏
  • 举报
回复
估计是升级的问题

有一部分文件没包含进来

你试试用VS2003新建一个

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧