GithubHelp home page GithubHelp logo

Comments (5)

GeertvanHorrik avatar GeertvanHorrik commented on July 24, 2024

For now I have a workaround:

var assemblyLoader = Type.GetType("Costura.AssemblyLoader");
var assembliesAsResourcesFieldInfo = assemblyLoader.GetField("assemblyNames", BindingFlags.Static | BindingFlags.NonPublic);
var assembliesAsResources = (Dictionary<string, string>) assembliesAsResourcesFieldInfo.GetValue(null);

var symbolsAsResourcesFieldInfo = assemblyLoader.GetField("symbolNames", BindingFlags.Static | BindingFlags.NonPublic);
var symbolsAsResources = (Dictionary<string, string>)symbolsAsResourcesFieldInfo.GetValue(null);

var readFromEmbeddedResourcesMethodInfo = assemblyLoader.GetMethod("ReadFromEmbeddedResources", BindingFlags.Static | BindingFlags.NonPublic);
foreach (var assemblyKeyValuePair in assembliesAsResources)
{
    Log.Debug("Forcing load from Costura packed assembly '{0}'", assemblyKeyValuePair.Key);

    readFromEmbeddedResourcesMethodInfo.Invoke(null, new object[] { assembliesAsResources, symbolsAsResources, assemblyKeyValuePair.Key });
}

from costura.

distantcam avatar distantcam commented on July 24, 2024

Costura was designed to package dependencies into a single exe and automatically handle loading those assemblies as the program runs. Costura is designed to do this seamlessly and automatically.

What you're wanting to do is to manually do what Costura does automatically. I think in that case Costura is not the solution and you should implement your own form of dependency injection, which seems to be what you've done with the work-around.

from costura.

GeertvanHorrik avatar GeertvanHorrik commented on July 24, 2024

Costura does exactly what I need:

Pack assemblies which are normally being optimized away by the C# compiler. With IncludeAssemblies I can still force these assemblies to be included and then can extract them again if I have to. I don't understand why this is a "no-go". I can even send you a pull request ;-)

from costura.

distantcam avatar distantcam commented on July 24, 2024

If Costura does exactly what you need then there's no need for a PR.

Manual assembly loading is not the goal of Costura. Costura is for automatic assembly loading.

This has the same problem as issue #27, specifically how do you call into Costura? There would have to be a reference assembly added as a placeholder, and calls to that placeholder would have to be redirected as part of the code weaving.

Since you already have a functioning work-around I don't see why this extra code needs to be added to Costura, increasing it's complexity, when it's already a rather complex project.

from costura.

GeertvanHorrik avatar GeertvanHorrik commented on July 24, 2024

A good example is a type which you need during deserialization. The types are not directly used, but must be loaded in order to be used. Then you can discuss whether this must be handled by the serialization engine, but this is unfortunately not in my control. Preloading the assemblies with costura is.

I am just looking for a simple option:

costura loadAssembliesOnStartup="true" (false by default)

which just loops through the list of assemblies and loads them. I don't think that will make it over-complex.

from costura.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.