简体   繁体   English

为什么我的应用程序中的dll文件永远不在程序中? 我需要将其复制到d:\\以便在那里运行我的应用程序frmo

[英]Why the dll file in my application is not in the program forever ? I needed to copy it to d:\ to run my application frmo there

I have this application that start like this: 我有这样启动的应用程序:

using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using DirectShowLib;
using System.Collections.Generic;
using Extracting_Frames;
using System.Windows.Forms;

In the application it self i did add a reference browsed and selected DirectShowLib-2005.dll Everything went ok untill i copied from my application directory debug the application exe file wich is in my case: LE.exe copied it to D:\\ 在应用程序中,我自己添加了浏览并选择DirectShowLib-2005.dll的引用,一切正常,直到我从应用程序目录中复制了调试应用程序exe文件为止(在我的情况下):LE.exe将其复制到D:\\

Once im running it im getting exception error. 一旦我运行它我得到异常错误。 So i copied to D:\\ also the file DirectShowLib-2005.dll and now its working. 所以我也将文件DirectShowLib-2005.dll复制到D:\\,现在它可以工作了。

The question is how do i make that the file DirectShowLib-2005.dll will be in the application forever without needing to copy it to any place on my hard disk when im trying to running my program from there ? 问题是当我试图从那里运行程序时,如何使DirectShowLib-2005.dll文件永远存在于应用程序中,而无需将其复制到硬盘上的任何位置? If its d:\\ E:\\ or any other location. 如果它是d:\\ E:\\或任何其他位置。

When Visual Studio builds your application it places everything it's needed to run it in the Output path specified for the targeted configuration (eg bin\\Debug\\ for Debug configuration). 当Visual Studio生成应用程序时,它将运行它所需的所有内容都放置在为目标配置指定的输出路径中(例如, bin\\Debug\\用于Debug配置)。

Because the DLL is a shared library its code is not embedded in your application and any reference to it is resolved at run time. 由于DLL是共享库,因此它的代码未嵌入您的应用程序中,并且对它的任何引用都在运行时解析。

If you simply want to run your application from a different location, the easiest way is to copy everything from the output folder . 如果您只是想从其他位置运行应用程序, 最简单的方法是从输出文件夹复制所有内容

If you struggle to merge the dependencies with your code you can use ILMerge or SmartAssembly . 如果您难以将依赖项与代码合并,则可以使用ILMergeSmartAssembly

Sometimes, some references might be critical for your application to start up properly but because Visual Studio does not copy all references to the output folder in most cases, you'll need to change the property of a reference CopyLocal to True so that the reference would be included in your application by default. 有时,某些引用对于您的应用程序正常启动可能至关重要,但是由于Visual Studio在大多数情况下不会将所有引用复制到输出文件夹,因此您需要将引用CopyLocal的属性更改为True以便引用可以默认情况下包含在您的应用程序中。


屏幕截图

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

相关问题 我有一个dll形式的应用程序,我想在我的控制台应用程序中运行它。 我怎么做 - i have a form application as a dll and i want to run it in my console application. how do i do that 无法在我的PHP应用程序中使用dll文件 - Unable to use dll file in my php application 为什么我的应用程序不读取我的DataAccessLayer.dll.config文件? - Why wont my application read my DataAccessLayer.dll.config file? 如何更快地使我的应用程序复制文件 - How to make my application copy file faster 为什么CASPol允许我的.NET应用程序运行? - Why is CASPol allowing my .NET application to run? 为什么我的应用程序在同一目录中找不到依赖的dll? - Why can't my application find a dependent dll in the same directory? 我如何在asp.net Web应用程序中调用嵌入dll中的javascript文件? - How do I call a javascript file that's embedded in a dll in my asp.net web application? 当我关闭应用程序时,我的程序仍在任务管理器中 - When I close my application my program is still in Task Manager 如何在我的C#程序面板中运行另一个应用程序? - How can I run another application within a panel of my C# program? 我的应用程序将以管理员身份运行吗? - Will my application run as administrator?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM