如何从 .cs 文件加载类 [英] How to load a class from a .cs file

查看:22
本文介绍了如何从 .cs 文件加载类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以加载一个类并从它的 .cs 文件中创建它的实例?

Is it possible to load a class and create Instance of it from It's .cs file?

我想在 .cs 文件中打开一个自定义类并在我的应用程序中创建它的实例

I want to open a custom class in a .cs file and create instance of it in my application

谢谢

推荐答案

理论上是的 - 这主要取决于您是否拥有所有可用的依赖项...

in theory yes - it mainly depends on whether you have all dependencies available...

如果你可以使用内置的CSharpCodeProvider.cs- 文件编译为程序集(如果需要,可以纯粹在内存中),然后使用反射创建实例/使用类从那个程序集...

IF so you can use the built-in CSharpCodeProvider to compile the .cs- file to an assembly (can be purely in-memory if need be) and then use Reflection to create an instance/use a class from that assembly...

由于没有提供太多细节,我建议您查看这些链接,并在出现问题时提出详细问题:

Since don't provide much detail I would suggest to checkout these links and come back with detail questions if some arrise:

这篇关于如何从 .cs 文件加载类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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