Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 嵌入DLL和引用XAML_C#_Wpf_Xaml - Fatal编程技术网

C# 嵌入DLL和引用XAML

C# 嵌入DLL和引用XAML,c#,wpf,xaml,C#,Wpf,Xaml,我有一个使用GMAP.Net和扩展WPF工具包的WPF应用程序。我直接在XAML中引用这些库中的控件。我想将这些DLL添加到我的项目中,并将它们标记为嵌入式资源 当我不再使用dll作为引用时,如何继续引用XAML中的控件 编辑:没有太多代码显示。当我使用gmap作为参考时,这是有效的 xmlns:WindowsPresentation="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation

我有一个使用GMAP.Net和扩展WPF工具包的WPF应用程序。我直接在XAML中引用这些库中的控件。我想将这些DLL添加到我的项目中,并将它们标记为嵌入式资源

当我不再使用dll作为引用时,如何继续引用XAML中的控件

编辑:没有太多代码显示。当我使用gmap作为参考时,这是有效的

xmlns:WindowsPresentation="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"
删除gmap作为引用并添加为嵌入资源后出现错误消息:

错误1命名空间“clr命名空间:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation”中不存在名称“GMapControl”。Windows\MapWindow.xaml


xmlns
intelissense/下拉列表中不存在gmap引用

保留引用的DLL,只是在构建最终版本时不要复制它们。另外,您是否向AssemblyResolve添加了代码以拉入嵌入的资源?我的代码使用gzip程序集

        AppDomain.CurrentDomain.AssemblyResolve += ( sender, args ) =>
        {
            try
            {
                String resourceName = String.Format( "Program.Libs.{0}.dll.gz", new AssemblyName( args.Name ).Name );
                using (var stream = new GZipStream( Assembly.GetExecutingAssembly().GetManifestResourceStream( resourceName ), CompressionMode.Decompress ))
                using (var outstream = new MemoryStream())
                {
                    CopyTo( stream, outstream );
                    return Assembly.Load( outstream.GetBuffer() );
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine( e.ToString() );
                return null;                    
            }
        };

    public static long CopyTo( Stream source, Stream destination )
    {
        byte[] buffer = new byte[ 2048 ];
        int bytesRead;
        long totalBytes = 0;
        while ((bytesRead = source.Read( buffer, 0, buffer.Length )) > 0)
        {
            destination.Write( buffer, 0, bytesRead );
            totalBytes += bytesRead;
        }
        return totalBytes;
    }

你试过什么吗?我已经从我的引用列表中删除了dll,并将它们作为嵌入资源添加到我的项目中。现在我的项目没有编译,因为我在XAML中的
xmlns
查找失败。gzip背后的原因是什么?我以前见过,只是为了让主exe更小。GZip可以很好地压缩,大约50%左右。