Junfeng Zhang

Random notes
随笔 - 47, 评论 - 299, 引用 - 74

导航

标签

每月存档

最新留言

广告

【第1页/共3页,32条】
首页
前页
1

How do I mix C# and C++ code in a single assembly?

How do I mix C# and C++ code in a single assembly?

 If your C++ code is not compiled with /clr:safe (i.e. it is compiled with /clr or /clr:pure), do the following:

1) compile your C++ code into .obj files

2) compile your C# code into a .netmodule, using /AddModule to reference the C++ .obj files

3) link the C# netmodule directly with the C++ object files using the C++ linker to create a mixed language assembly 

 If your C++ code is compiled with /clr:safe, build your C++ code as a .netmodule.  You can use it just like you would use a .netmodule from any other language.

This applies to .Net framework beta2+.

posted on 2005-05-25 16:15:00 by junfeng  评论(14) 阅读(8483)

MSDN: Designing .NET Class Libraries

MSDN新推出了一个系列

http://msdn.microsoft.com/netframework/programming/classlibraries/

Designing .NET Class Libraries

The Designing .NET Class Libraries series presents design guidelines for developing classes and components that extend the .NET Framework. The goal of the Designing .NET Class Libraries series is to encourage consistency and predictability in public APIs while enabling Web and cross-language integration. The guidelines presented in Designing .NET Class Libraries are intended to help class library designers understand the trade-offs between different solutions. There might be situations where good library design requires that you violate these design guidelines. Such cases should be rare, however it is important that you provide a solid justification for your decision.

每一个讲座都带有一段录象. 这些录象其实是微软内部的课程.

如果你的工作涉及设计类库的话, 这可能是你最好的资源了.

 

posted on 2005-03-21 10:06:00 by junfeng  评论(10) 阅读(3969)

另一位C++大师的blog

如果你关心VC 2005的话,你应该阅读Stan Lippman的blog.

http://blogs.msdn.com/slippman

Stan Lippman写的<<C++ Primer>>,可能是世界上最流行的C++入门书了.

posted on 2004-12-10 18:20:00 by junfeng  评论(16) 阅读(7369)

Herb Sutter 讨论 C++/CLI's deterministic destruction

Herb Sutter在他的blog上讨论了C++/CLI的deterministic destruction.

http://pluralsight.com/blogs/hsutter/archive/2004/11/23/3666.aspx

Herb Sutter是C++ Standard Committee 的主席.他现在在微软主持VC 2005(即C++/CLI)的设计.

posted on 2004-12-10 18:14:00 by junfeng  评论(9) 阅读(3846)

NGEN and Startup Performance

每个人都说Ngen可以加快程序的启动速度.可到底有多大作用呢?

Rico 给了个例子:

Cold Startup Performance

他的数据表明,NGEN最大的作用还是在warm startup的时候.如果你有多个程序运行的话,基本上就是warm startup了. 

posted on 2004-11-02 16:52:00 by junfeng  评论(12) 阅读(4338)

.Net Framework Service Pack and Publisher Policy

有朋友问为什么.Net Framework Service Pack没有用publisher policy.

下面是我的一个回答:

http://blogs.msdn.com/junfeng/archive/2004/10/11/240822.aspx

There are several reasons:

1. Publisher Policy can be opted out by applications.

In App.Config you can say publisherPolicy="No", effectively ignore any publisher policy. Majority of the fixes in SP are security fixes. We don't want people to opt out security fixes.

In retrospection, the reason we introduce publisherPolicy="No" is for app compat. Since then the thinking has been shifted to security first.

2. Framework assemblies are tested in a group. And we want to ship them in a group.

This is the same reason we introduce framework unification policy. We tested all the framework assemblies in redist SP together. And we ship them together. Say we shipped publisher policy. If you intend to opt out publisher policy, you end up with a configuration we did not test, and we do not want to support. Of course if you do not intend to opt out publisher policy, then it makes no difference for you whether we use publisher policy or not. 

The bottom line is the current policy system is not optimal for .Net framework Servicing, and we intend to change that in future releases.

posted on 2004-10-25 15:25:00 by junfeng  评论(153) 阅读(6657)

C++: The Most Powerful Language for .NET Framework Programming

这是MSDN上的一篇介绍VC++2005的文章.

http://msdn.microsoft.com/visualc/default.aspx?pull=/library/en-us/dnvs05/html/VS05Cplus.asp

我现在也在学习VC++2005,有时间写一点心得.

posted on 2004-08-19 05:53:00 by junfeng  评论(8) 阅读(3820)

另一个.Net collection

C5 http://www.itu.dk/research/c5/

 C5 is a library of generic collection classes for the upcoming version 2.0 of the .Net platform. C5 extends the standard .Net System.Collections.Generic namespace with tree data structures, heap based priority queues and hash indexed array lists and linked lists, making it more comprehensive than most collection class libraries on similar platforms. Unlike many other collection class libraries, C5 is designed with a strict policy of supporting "code to interface not implementation".

之所以看到那么多的Collection,我想还是因为.Net framework现在没有提供完整的数据结构.我的intern就向我抱怨说.Net framework 1.1里没有linkedList和Tree.

posted on 2004-08-07 01:34:00 by junfeng  评论(8) 阅读(3791)

PowerCollections

Jeffrey Richter和他的在Wintellect的朋友开始了一个Open Source的项目

PowerCollectiolns

http://www.wintellect.com/powercollections/

他们的目的是要实现更多的.Net Collection.

数据结构这种东西,作为一个社区项目可能更合理一些.

posted on 2004-08-06 02:27:00 by junfeng  评论(8) 阅读(3913)

关于Domain Neutral Assemblies

在我的英文blog上发表了一篇关于Domain Neutral Assemblies的文章.

http://blogs.msdn.com/junfeng/archive/2004/08/05/208375.aspx

很抱歉没有中文版.如果谁有兴趣帮忙的话不胜感激.

posted on 2004-08-05 12:12:00 by junfeng  评论(9) 阅读(2198)

Improving .NET Application Performance and Scalability

如果你注重你的.Net程序的性能的话,你绝对应该读读这本书.

http://msdn.microsoft.com/netframework/archive/default.aspx?pull=/library/en-us/dnpag/html/scalenet.asp

 

posted on 2004-07-21 17:09:00 by junfeng  评论(7) 阅读(1998)

MultiModule Assemblies

我在我的英文blog上发表了一篇关于MultiModule assemblies的文章 http://blogs.msdn.com/junfeng/archive/2004/07/15/183813.aspx.

比较有意义的是,在VC++ 2005里, link.exe可以把多个netmodule连接成一个assembly.这个东东很多人已经期待很久了.

posted on 2004-07-21 17:03:00 by junfeng  评论(0) 阅读(1673)

VC++ 2005

不知道有多少人注意VC++ 2005。在我们这里,有很多人对VC++ 2005很兴奋。有些人认为,VC++ 2005会把很大一部分程序员从C#阵营转到VC里:)

Stephen Toub的这篇文章是一个很好的总结。

Write Faster Code with the Modern Language Features of Visual C++ 2005
http://msdn.microsoft.com/msdnmag/issues/04/05/visualc2005/default.aspx

以Hello, World结尾吧。

C:\HelloWorld>more hello.cpp
int main()
{
    System::Console::WriteLine("Hello, World!");
    return 0;
}

C:\HelloWorld>cl hello.cpp /clr吐舌笑脸ure
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40607.16
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright 咖啡 Microsoft Corporation.  All rights reserved.

hello.cpp
Microsoft (R) Incremental Linker Version 8.00.40607.16
Copyright 咖啡 Microsoft Corporation.  All rights reserved.

/out:hello.exe
/clrimagetype吐舌笑脸ure
hello.obj

C:\HelloWorld>hello
Hello, World!

posted on 2004-07-09 15:10:00 by junfeng  评论(45) 阅读(14982)

What is new in fusion in .Net framework 2.0 (9) --- gcServer

Use the following app.config to enable server GC.

<configuration>
  <runtime>
    <gcServer enabled="true" />
  </runtime>
</configuration>

Use System.Environment.IsServerGC to check if server GC is turned on or not.

posted on 2004-07-09 14:59:00 by junfeng  评论(6) 阅读(2228)

What is new in fusion in .Net framework 2.0 (8) --- Caching binding failures

Gotdotnet.com 上发表的break changes from version 1.1 to 2.0 上有一条:

 

Cache load failures in order to ensure that different app domains do not have different dependency loading success/failure characteristics in domain neutral sharing scenarios

 

http://www.gotdotnet.com/team/changeinfo/Backwards1.1to2.0/default.aspx#00000067

 

link里有说明这是怎么回事。简单的说,在同一个AppDomain里,如果 Assembly.Load/Assembly.LoadFrom()第一次失败了的话,以后同一个Assembly.Load()/Assembly.LoadFrom()会继续失败,并且会返回同一个exception,即使你在第一次和第二次之间把assembly拷到正确的地方。

 

举个例子。假设a.dllc:\temp\a.dll 现在当前AppDomainAppBasec:\myapp.

 

Assembly.Load(“A, version=0.0.0.0, culture=neutral, publickeytoken=0123456789abcde”眨眼笑脸;  // will fail with FileNotFoundException since a.dll is not in c:\myapp;

File.Copy(“c:\\temp\\a.dll”, “c:\\myapp\a.dll”眨眼笑脸;

Assembly.Load(“A, version=0.0.0.0, culture=neutral, publickeytoken=0123456789abcde”眨眼笑脸;  // this will succeed in 1.0/1.1, but will fail in 2.0, since in 2.0 the binding failure of the first bind is cached.

 

这个改变的原因是让assembly binding in one AppDomain有个一致的行为。第一次成功了,以后就会成功。第一次失败了,以后就会失败。

 

当然最根本的原因是为了共享。没有这个保证的话共享是不可能的。

posted on 2004-07-07 17:04:00 by junfeng  评论(1) 阅读(1532)

【第1页/共3页,32条】
首页
前页
1

Powered by: Joycode.MVC引擎 0.5.2.0