在VC++.net 2003中为什么只能看到Struct,看不到Class!冰天雪地赤身裸体求救!

youercsdn 2004-11-24 11:57:53
为了声称DLL,我在VC++.net 2003中新建了.NET类库,默认生成的类:
namespace My
{
public __gc class Class1
{
// TODO: 在此添加此类的方法。

public:
void tt()
{

}
};
}

生成DLL后,可以在其他的项目中引用并使用其方法;
当我将public __gc 去掉后,在其他的项目中就只能看到同名的Struct,看不到Class了!
怎么办!
...全文
139 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
cppTrier 2004-11-27
  • 打赏
  • 举报
回复
原来那个类是native的话,你可以写一个__gc的包装类,在MC++里面,managed和unmanaged type是可以互相调用的
cppTrier 2004-11-27
  • 打赏
  • 举报
回复
不能去掉,去掉__gc的话,编译器会把这个类当作一个native type。对native type的编译和managed type是不一样的。

native type的编译是这样:将类编译成一个只包含数据成员的struct,把所有的方法编译为以类名开头泊一个全局方法。所以会有你那样的情况,要让C#调用的话,不能是native type
youercsdn 2004-11-27
  • 打赏
  • 举报
回复
代码量很大,改起来很麻烦!
北京的雾霾天 2004-11-25
  • 打赏
  • 举报
回复
那你用托管的形式来写啊,在C#里调用托管的最好使啊.为什么要写成非托管的DLL啊.
youercsdn 2004-11-24
  • 打赏
  • 举报
回复
我要在C#中调用,如果用WIN32的DLL,调用起来比较麻烦!
北京的雾霾天 2004-11-24
  • 打赏
  • 举报
回复
我没有见过那个错误,我不明白,你为什么不用MFC类型的DLL而一定要用.NET的呢,这样混合编程好用吗?
我不会这样做.
youercsdn 2004-11-24
  • 打赏
  • 举报
回复
对了遇到下面的错误该怎么办!
error LNK2020: 无法解析的标记(0A00004A) delete[]
北京的雾霾天 2004-11-24
  • 打赏
  • 举报
回复
我帮你看一下.
北京的雾霾天 2004-11-24
  • 打赏
  • 举报
回复
???
不会了.....
youercsdn 2004-11-24
  • 打赏
  • 举报
回复
如果要使用其中的方法该怎么办!
例如:
namespace soplex
{
class SPxPricer;
class SPxRatioTester;
class SPxStarter;
class SPxScaler;
class SPxSimplifier;

class SoPlex : public SPxLP, protected SPxBasis
{
friend class SPxFastRT;

public:
enum Representation
{
ROW = -1, ///< rowwise representation.
COLUMN = 1 ///< columnwise representation.
};


enum Type
{
/// Entering Simplex.
/** The Simplex loop for the entering Simplex can be sketched
* as follows:
* - \em Pricing : Select a variable to #ENTER the basis.
* - \em Ratio-Test : Select variable to #LEAVE the
* basis such that the basis remains feasible.
* - Perform the basis update.
*/
ENTER = -1,
/// Leaving Simplex.
/** The Simplex loop for the leaving Simplex can be sketched
* as follows:
* - \em Pricing: Select a variable to #LEAVE the basis.
* - \em Ratio-Test: Select variable to #ENTER the
* basis such that the basis remains priced.
* - Perform the basis update.
*/
LEAVE = 1
};

/// Pricing type.
/** In case of the #ENTER%ing Simplex algorithm, for performance
* reasons it may be advisable not to compute and maintain up to
* date vectors #pVec() and #test() and instead compute only some
* of its elements explicitely. This is constroled by the #Pricing type.
*/
enum Pricing
{
/// Full pricing.
/** If #FULL pricing in selected for the #ENTER%ing Simplex,
* vectors #pVec() and #test() are kept up to date by
* #SoPlex. An #SPxPricer only needs to select an #Id such
* that the #test() or #coTest() value is < 0.
*/
FULL,
/// Partial pricing.
/** When #PARTIAL pricing in selected for the #ENTER%ing
* Simplex, vectors #pVec() and #test() are not set up and
* updated by #SoPlex. However, vectors #coPvec() and
* #coTest() are still kept up to date by #SoPlex.
* An #SPxPricer object needs to compute the values for
* #pVec() and #test() itself in order to select an
* appropriate pivot with #test() < 0. Methods #computePvec(i)
* and #computeTest(i) will assist the used to do so. Note,
* that it may be feasable for a pricer to return an #Id with
* #test() > 0; such will be rejected by #SoPlex.
*/
PARTIAL
};

enum VarStatus
{
ON_UPPER, ///< variable set to its upper bound.
ON_LOWER, ///< variable set to its lower bound.
FIXED, ///< variable fixed to identical bounds.
ZERO, ///< free variable fixed to zero.
BASIC ///< variable is basic.
};

/**@todo In spxchange and at loadbasis, change the status to
if (m_status > 0) m_status = REGULAR;
*/
enum Status
{
ERROR = -9, ///< an error occured.
NOT_INIT = -8, ///< not initialised error
ABORT_TIME = -7, ///< #solve() aborted due to time limit.
ABORT_ITER = -6, ///< #solve() aborted due to iteration limit.
ABORT_VALUE = -5, ///< #solve() aborted due to objective limit.
SINGULAR = -4, ///< Basis is singular, numerical troubles?
NO_PROBLEM = -3, ///< No Problem has been loaded.
REGULAR = -2, ///< LP has a usable Basis (maybe LP is changed).
RUNNING = -1, ///< algorithm is running
UNKNOWN = 0, ///< nothing known on loaded problem.
OPTIMAL = 1, ///< LP has been solved to optimality.
UNBOUNDED = 2, ///< LP has been proven to be primal unbounded.
INFEASIBLE = 3 ///< LP has been proven to be primal infeasible.
};
youercsdn 2004-11-24
  • 打赏
  • 举报
回复
可以,因为原来的代码就是非托管的!
北京的雾霾天 2004-11-24
  • 打赏
  • 举报
回复
当你把public 和__gc一块去掉了那么这个DLL里的类就不能公开了,也不能在其它的项目中用这个类了.
北京的雾霾天 2004-11-24
  • 打赏
  • 举报
回复
你去掉了能编译通过吗?
北京的雾霾天 2004-11-24
  • 打赏
  • 举报
回复
不能去的,这是VC的语法啊,这样才能生成一个类啊/
youercsdn 2004-11-24
  • 打赏
  • 举报
回复
是否可以像非托管的那样使用!
youercsdn 2004-11-24
  • 打赏
  • 举报
回复
如果非要去掉,那么类的方法该怎么用!
北京的雾霾天 2004-11-24
  • 打赏
  • 举报
回复
你为什么要去掉__gc啊,这个不能去的.和C#的不一样的.

7,540

社区成员

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

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