简体   繁体   English

C#中的静态链接?

[英]Static linking in C#?

The Windows Azure client libraries are very big (several MBs), and I have a fairly small project (on the order of a few hundred KBs) that uses only a few functions from them. Windows Azure客户端库非常大(几MB),我有一个相当小的项目(大约几百KB),只使用它们中的一些功能。 Is there a way for me to link in those functions at build time, so that the resultant DLL doesn't get hugely bloated, and I don't have to link the functions in at runtime? 有没有办法让我在构建时链接这些函数,以便生成的DLL不会变得非常臃肿,我不必在运行时链接函数?

Something like this http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx , but I get the impression that bundles in the whole DLL. 像这样的东西http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx ,但我得到了捆绑在整个DLL中的印象。

Thanks! 谢谢!

Edit: Because there are external constraints on the size of the final deliverable DLL, inflating it this much is an absolute last resort - the only other option I'm aware of is just to duplicate the code I use verbatim. 编辑:因为最终可交付DLL的大小存在外部约束,所以对它进行充气是绝对的最后手段 - 我唯一知道的另一个选择就是复制我逐字使用的代码。

In a word: No . 总之一句:

Remember that even though you only use a few functions, there are likely many other function in the library that those functions use, that you don't even know about! 请记住,即使您只使用了一些函数,库中也可能存在许多其他函数,这些函数使用的是您甚至不知道的!

You can't do this, because you don't have access to all the dependencies. 您无法执行此操作,因为您无权访问所有依赖项。 Remember also that those dependencies may even reside in another DLL, and you need to include that entire DLL for the same reason. 也请记住,这些依赖甚至可能存在于另一个DLL,你需要包括同样原因整个DLL。

What you are looking for sounds very like .NET Native . 你在寻找什么听起来很像.NET Native Unfortunately for you, its only preview and right now works only with Store Apps for devices. 不幸的是,它的唯一预览现在只适用于Store Apps for devices。 Statements like this 这样的陈述

We will continue to evolve and improve native compilation for the range of .NET applications 我们将继续发展和改进.NET应用程序的本机编译

can be found on the internet but nothing specific about web apps\\Azure. 可以在互联网上找到,但没有关于网络应用程序\\ Azure的具体内容。

Until then, answer is No 在那之前,答案是否定的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM