如何在 .Net 应用程序中使 DLL 成为可选

发布于 2024-11-15 05:40:02 字数 280 浏览 7 评论 0原文

我们有一个应用程序需要完全信任,因为存在 Chilkat .NET 3.5 DLL 这并不是一个大问题,但是我们希望将我们的应用程序提交到:Windows Web 应用程序库,并且它必须是中等信任

因此,为了使其中等信任,我们需要做的就是

  • 删除对 DLL 的引用,
  • 注释掉与该代码相关的方法

,而不是制作 2 个不同版本的应用程序,删除对 DLL 的引用的最佳方法是什么?该应用程序的一个版本?

谢谢!

We have an app the requires Full Trust because of a Chilkat .NET 3.5 DLL
This has not been a huge issue, however we would like to submit our app to the: Windows Web Application Gallery and it must be Medium Trust.

So to make it medium trust all we need to do is

  • remove the reference to the DLL
  • comment out the methods that tie into that code

Rather than making 2 different versions of the app, what is the best approach to remove the reference to the DLL for one version of the app?

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪了杯 2024-11-22 05:40:02

这不是一个简单的问题,但我对此的第一个想法是使用接口将其抽象出来并稍后将其绑定,但您必须记住在加载它时检查您是否完全信任,否则它可能无法工作。

static class Program
{
    static void Main(string[] args)
    {
        Assembly asm = Assembly.Load("ExampleAssembly, Version=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012");
        IFullTrustAddin addin = asm.CreateInstance("Namespace.MyChilkatWrapper") as IFullTrustAddin;

        if (addin == null)
            return;

        addin.DoSomething();
    }
}

interface IFullTrustAddin
{
    void DoSomething();
}

That’s not a simple one, but my first thoughts on this would be to abstract it out with and interface and late bind it in, but you must remember to check you have full trust when you load it or it might not work.

static class Program
{
    static void Main(string[] args)
    {
        Assembly asm = Assembly.Load("ExampleAssembly, Version=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012");
        IFullTrustAddin addin = asm.CreateInstance("Namespace.MyChilkatWrapper") as IFullTrustAddin;

        if (addin == null)
            return;

        addin.DoSomething();
    }
}

interface IFullTrustAddin
{
    void DoSomething();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文