Click here to Skip to main content
15,850,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to read .dbc file in C#? Pin
Matt Slay24-Apr-20 17:33
Matt Slay24-Apr-20 17:33 
QuestionObject Tracking With A Web Cam Pin
Kevin Marois19-Apr-20 11:19
professionalKevin Marois19-Apr-20 11:19 
QuestionObject Tracking With A Web Cam Pin
Kevin Marois19-Apr-20 11:19
professionalKevin Marois19-Apr-20 11:19 
AnswerRe: Object Tracking With A Web Cam Pin
Pete O'Hanlon19-Apr-20 22:26
subeditorPete O'Hanlon19-Apr-20 22:26 
GeneralRe: Object Tracking With A Web Cam Pin
Kevin Marois20-Apr-20 7:03
professionalKevin Marois20-Apr-20 7:03 
GeneralRe: Object Tracking With A Web Cam Pin
Kevin Marois20-Apr-20 9:44
professionalKevin Marois20-Apr-20 9:44 
GeneralRe: Object Tracking With A Web Cam Pin
Pete O'Hanlon20-Apr-20 11:55
subeditorPete O'Hanlon20-Apr-20 11:55 
QuestionMake a single exe application - costura.fody - AppDomain.CurrentDomain.AssemblyResolve Pin
andla119-Apr-20 9:19
andla119-Apr-20 9:19 
I have tried many things before I found costura.fody and I were hoping that would be the solution to create a single file exe of a cefsharp application that I'm doing.

So the help file for costura.fody says to set the copy local to true of the file you want to embed in the solution explorer. Done that.

So the exe got a little bit bigger when I did that but I notice that the size was not even close to cover libcef.dll so I suspected that this file was not embedded.

I tested this by renaming the dll in the output folder and yes I couldn't run the application.

I would really love for this to work but I'm kind of giving up. I was struggling with AppDomain.CurrentDomain.AssemblyResolve to tap into that event but it was never called. Even when defining it in the static constructor to make sure it is started before anything else.
I'm currently using this code:

C#
[STAThread]
public static void Main(string[] args)
{
    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveAssembly);
}


Just to clarify things, I'm using a windows forms project and I'm trying to make it as close to the examples I can find online. I would prefer to just add it in the Form1 constructor.
It should be calling this function
C#
private static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
{
    throw new NotImplementedException();
}


But it never does.

In the .csproj file tried this snippet.

<Target Name="Prebuild">
   <CallTarget Targets="Clean" />
   <MSBuild Projects="$(SolutionPath)" Targets="Build" Properties="Configuration=Debug;IgnoreRecursion=true" />
 </Target>
 <Target Name="BeforeBuild">
   <ItemGroup>
     <_IgnoreRecursion Include="$(IgnoreRecursion)"/>
   </ItemGroup>
   <CallTarget Targets="Prebuild" Condition="'%(_IgnoreRecursion.Identity)' != 'true'" />
   <CreateItem Include="$(TargetDir)\**\*.*">
     <Output TaskParameter="Include" ItemName="OutputFiles" />
   </CreateItem>
   <ItemGroup>
     <EmbeddedResource Include="@(OutputFiles)" Condition="('%(OutputFiles.Extension)' == '.dll' Or '%(OutputFiles.Extension)' == '.pdb')">
       <LogicalName>%(OutputFiles.DestinationSubDirectory)%(OutputFiles.Filename)%(OutputFiles.Extension)</LogicalName>
     </EmbeddedResource>
   </ItemGroup>
   <Message Importance="high" Text="Embedding: @(OutputFiles->'%(Filename)%(Extension)', ', ')" />
 </Target>


This embeds the dll's fine. I just wish ResolveAssembly could be called. If it was I could have this code taking care of the lost dll's
//static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
//{
//    return null;
//    //var currentAssembly = Assembly.GetExecutingAssembly();
//    //var requiredDllName = $"{(new AssemblyName(args.Name)).Name}.dll";
//    //var resource = currentAssembly.GetManifestResourceNames().Where(s => s.EndsWith(requiredDllName)).FirstOrDefault();
//    //if (resource != null)
//    //{
//    //    using (var stream = currentAssembly.GetManifestResourceStream(resource))
//    //    {
//    //        if (stream == null)
//    //        {
//    //            return null;
//    //        }
//    //        var block = new byte[stream.Length];
//    //        stream.Read(block, 0, block.Length);
//    //        return Assembly.Load(block);
//    //    }
//    //}
//    //else
//    //{
//    //    return null;
//    //}
//}



Can anyone please help me with this?

Kind regards andla
AnswerRe: Make a single exe application - costura.fody - AppDomain.CurrentDomain.AssemblyResolve Pin
Richard MacCutchan19-Apr-20 22:54
mveRichard MacCutchan19-Apr-20 22:54 
GeneralRe: Make a single exe application - costura.fody - AppDomain.CurrentDomain.AssemblyResolve Pin
andla120-Apr-20 7:23
andla120-Apr-20 7:23 
GeneralRe: Make a single exe application - costura.fody - AppDomain.CurrentDomain.AssemblyResolve Pin
Dave Kreskowiak20-Apr-20 9:35
mveDave Kreskowiak20-Apr-20 9:35 
GeneralRe: Make a single exe application - costura.fody - AppDomain.CurrentDomain.AssemblyResolve Pin
andla121-Apr-20 4:33
andla121-Apr-20 4:33 
GeneralRe: Make a single exe application - costura.fody - AppDomain.CurrentDomain.AssemblyResolve Pin
andla121-Apr-20 4:46
andla121-Apr-20 4:46 
GeneralRe: Make a single exe application - costura.fody - AppDomain.CurrentDomain.AssemblyResolve Pin
Dave Kreskowiak21-Apr-20 5:03
mveDave Kreskowiak21-Apr-20 5:03 
QuestionRestSharp poser Pin
pkfox18-Apr-20 9:57
professionalpkfox18-Apr-20 9:57 
AnswerRe: RestSharp poser Pin
Gerry Schmitz18-Apr-20 12:04
mveGerry Schmitz18-Apr-20 12:04 
GeneralRe: RestSharp poser Pin
pkfox18-Apr-20 23:00
professionalpkfox18-Apr-20 23:00 
QuestionStatus Of Printing Files Pin
Member 1480498517-Apr-20 3:59
Member 1480498517-Apr-20 3:59 
AnswerRe: Status Of Printing Files Pin
Richard Deeming17-Apr-20 4:51
mveRichard Deeming17-Apr-20 4:51 
QuestionJoin 3 tables error : Incorrect syntax near '.'. Pin
Member 1266420916-Apr-20 4:59
Member 1266420916-Apr-20 4:59 
AnswerRe: Join 3 tables error : Incorrect syntax near '.'. Pin
Richard Deeming16-Apr-20 5:01
mveRichard Deeming16-Apr-20 5:01 
GeneralRe: Join 3 tables error : Incorrect syntax near '.'. Pin
Member 1266420916-Apr-20 5:10
Member 1266420916-Apr-20 5:10 
GeneralRe: Join 3 tables error : Incorrect syntax near '.'. Pin
Richard Deeming16-Apr-20 5:23
mveRichard Deeming16-Apr-20 5:23 
GeneralRe: Join 3 tables error : Incorrect syntax near '.'. Pin
Member 1266420916-Apr-20 6:07
Member 1266420916-Apr-20 6:07 
GeneralRe: Join 3 tables error : Incorrect syntax near '.'. Pin
Richard Deeming16-Apr-20 6:10
mveRichard Deeming16-Apr-20 6:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.