Мне нужно создать исполняемый файл, который затем создает собственный исполняемый файл.
Проблема в том, что я использую встроенные ресурсы ... они также должны быть внутри скомпилированного exe.
Итак, вопрос в том, что здесь не так?:
Я использую следующие опции компилятора для сборки:
cp.IncludeDebugInformation = false;
cp.GenerateExecutable = true;
cp.GenerateInMemory = false;
cp.ReferencedAssemblies.Add("System.dll");
cp.ReferencedAssemblies.Add("System.Drawing.dll");
cp.ReferencedAssemblies.Add("System.Management.dll");
cp.ReferencedAssemblies.Add("System.Windows.Forms.dll");
cp.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll");
cp.ReferencedAssemblies.Add("Microsoft.CSharp.dll");
cp.ReferencedAssemblies.Add(AppDomain.CurrentDomain.BaseDirectory +"\\Resources" + "\\IconLib.dll");
cp.ReferencedAssemblies.Add(AppDomain.CurrentDomain.BaseDirectory + "\\Resources" + "\\Microsoft.Office.Interop.Outlook.dll");
cp.EmbeddedResources.Add(AppDomain.CurrentDomain.BaseDirectory + "\\Resources" + "\\IconLib.dll");
cp.EmbeddedResources.Add(AppDomain.CurrentDomain.BaseDirectory + "\\Resources" + "\\outlook.ico");
cp.EmbeddedResources.Add(AppDomain.CurrentDomain.BaseDirectory + "\\Resources" + "\\Source.cs");
cp.CompilerOptions = "/filealign:0x00200 /optimize+ /platform:X86 /debug- /target:winexe";
Exe соответствует exe-файлу и включенным dll, как Microsoft.и IconLib.dll, кажется, работают, приложение может взаимодействовать, но!
Когда скомпилированный exe пытается получить доступ к ресурсу, например, outlook.ico, он падает.
Вот вызов для ресурса:
var notification = new System.Windows.Forms.NotifyIcon()
{
Visible = true,
**Icon = Main.Properties.Resources.outlook,**
BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info,
BalloonTipTitle = TT,
BalloonTipText = Tt,
};
Приложение аварийно завершает работу, когдавызывая этот встроенный ресурс.Как я могу это исправить?
namsespace Свойства целевого exe:
namespace Main.Properties {
using System;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Main.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static byte[] IconLib {
get {
object obj = ResourceManager.GetObject("IconLib", resourceCulture);
return ((byte[])(obj));
}
}
internal static System.Drawing.Icon outlook {
get {
object obj = ResourceManager.GetObject("outlook", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
internal static string Source {
get {
return ResourceManager.GetString("Source", resourceCulture);
}
}
}
}
Являются ли коды для встраивания ресурсов неправильными?Он использует другую папку для звонков, чем ресурсы?мне нужно связать их?много вопросов здесь.