GithubHelp home page GithubHelp logo

costura's Introduction

Costura is an add-in for Fody

Embeds dependencies as resources.

Chat on Gitter NuGet Status

See Milestones for release notes.

This is an add-in for Fody

It is expected that all developers using Fody become a Patron on OpenCollective. See Licensing/Patron FAQ for more information.

!!! READ THIS !!! Package is in maintenance mode !!! READ THIS !!!

In .NET Core 3 there are two new features:

With these features included in the dotnet tool set, the value proposition of Costura is greatly diminished.

Therefore we strongly recommend to try out the alternatives mentioned above.

Supported use cases

Costura will be kept in maintenance mode for the following use-cases because they are used by the maintainers:

  • C# projects (we have no experience with VB.NET, nor have any intention supporting this)
  • Library linking (e.g. embed dependencies in library projects)
  • Exe linking (e.g. embed dependencies in exe projects)
  • Windows platforms
  • Any advanced scenario that you are not willing to contribute (money, PR, etc) after discussing with the core contributes first

Non-supported use cases

  • VB.NET (see above)
  • Windows Services
  • Non-Windows platforms

Note that this list may be updated and will become more strict over time.

NuGet installation

Install the Costura.Fody NuGet package and update the Fody NuGet package:

PM> Install-Package Fody
PM> Install-Package Costura.Fody

The Install-Package Fody is required since NuGet always defaults to the oldest, and most buggy, version of any dependency.

Add to FodyWeavers.xml

Add <Costura/> to FodyWeavers.xml

<Weavers>
  <Costura/>
</Weavers>

How it works

Merge assemblies as embedded resources

This approach uses a combination of two methods

Details

This Task performs the following changes

  • Take all assemblies (and pdbs) that have been marked as "Copy Local" and embed them as resources in the target assembly.
  • Injects the following code into the module initializer of the target assembly. This code will be called when the assembly is loaded into memory

eg

static <Module>()
{
    ILTemplate.Attach();
}

Configuration Options

All config options are accessed by modifying the Costura node in FodyWeavers.xml.

Default FodyWeavers.xml:

<Weavers>
  <Costura />
</Weavers>

CreateTemporaryAssemblies

This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.

Defaults to false

<Costura CreateTemporaryAssemblies='true' />

IncludeDebugSymbols

Controls if .pdbs for reference assemblies are also embedded.

Defaults to true

<Costura IncludeDebugSymbols='false' />

IncludeRuntimeReferences

Controls whether the runtimes folder, used by .NET Core, for the embedded dependencies will be embedded.

Defaults to true

<Costura IncludeRuntimeReferences='false' />

UseRuntimeReferencePaths

Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.

For example, the reference system.text.encoding.codepages\5.0.0\runtimes\win\lib\net461\System.Text.Encoding.CodePages.dll will be embedded as costura.system.text.encoding.codepages.dll.compressed when false, so Costura will automatically load it.

It will be embedded as costura.runtimes.win.lib.net461.system.text.encoding.codepages.dll.compressed when true (given IncludeRuntimeReferences='true' and IncludeRuntimeAssemblies='System.Text.Encoding.CodePages'), requiring custom user code to load the embedded compressed assembly.

Defaults to false when the weaved assembly targets .NET Framework, true when the weaved assembly targets .NET Core

<Costura UseRuntimeReferencePaths='true' />

DisableCompression

Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.

Defaults to false

<Costura DisableCompression='true' />

DisableCleanup

As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.

Defaults to false

<Costura DisableCleanup='true' />

LoadAtModuleInit

Costura by default will load as part of the module initialization. This flag disables that behaviour. Make sure you call CosturaUtility.Initialize() somewhere in your code.

Defaults to true

<Costura LoadAtModuleInit='false' />

IgnoreSatelliteAssemblies

Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.

Be advised, that DLL project assembly names ending with '.resources' (resulting in *.resources.dll will lead to errors when this flag set to false.

Defaults to false

<Costura IgnoreSatelliteAssemblies='true' />

ExcludeAssemblies / ExcludeRuntimeAssemblies

A list of assembly names to exclude from the default action of "embed all Copy Local references".

Do not include .exe or .dll in the names.

Can not be defined with IncludeAssemblies.

Can use wildcards for partial assembly name matching. For example System.* will exclude all assemblies that start with System.. Wildcards may only be used at the end of an entry so for example, System.*.Private.* would not work.

Can take two forms.

As an element with items delimited by a newline.

<Costura>
  <ExcludeAssemblies>
    Foo
    Bar
  </ExcludeAssemblies>
</Costura>

Or as an attribute with items delimited by a pipe |.

<Costura ExcludeAssemblies='Foo|Bar' />

IncludeAssemblies / IncludeRuntimeAssemblies

A list of assembly names to include from the default action of "embed all Copy Local references".

Do not include .exe or .dll in the names.

Can not be defined with ExcludeAssemblies / IncludeRuntimeAssemblies.

Can use wildcards at the end of the name for partial matching.

Can take two forms.

As an element with items delimited by a newline.

<Costura>
  <IncludeAssemblies>
    Foo
    Bar
  </IncludeAssemblies>
</Costura>

Or as an attribute with items delimited by a pipe |.

<Costura IncludeAssemblies='Foo|Bar' />

Unmanaged32Assemblies & Unmanaged64Assemblies

Mixed-mode assemblies cannot be loaded the same way as managed assemblies.

Therefore, to help Costura identify which assemblies are mixed-mode, and in what environment to load them in you should include their names in one or both of these lists.

Do not include .exe or .dll in the names.

Can use wildcards at the end of the name for partial matching.

Can take two forms.

As an element with items delimited by a newline.

<Costura>
  <Unmanaged32Assemblies>
    Foo32
    Bar32
  </Unmanaged32Assemblies>
  <Unmanaged64Assemblies>
    Foo64
    Bar64
  </Unmanaged64Assemblies>
</Costura>

Or as a attribute with items delimited by a pipe |.

<Costura
    Unmanaged32Assemblies='Foo32|Bar32' 
    Unmanaged64Assemblies='Foo64|Bar64' />

Native Libraries and PreloadOrder

Native libraries can be loaded by Costura automatically. To include a native library include it in your project as an Embedded Resource in a folder called costura32 or costura64 depending on the bittyness of the library.

Optionally you can also specify the order that preloaded libraries are loaded. When using temporary assemblies from disk mixed mode assemblies are also preloaded.

To specify the order of preloaded assemblies add a PreloadOrder element to the config.

<Costura>
  <PreloadOrder>
    Foo
    Bar
  </PreloadOrder>
</Costura>

Or as a attribute with items delimited by a pipe |.

<Costura PreloadOrder='Foo|Bar' />

CosturaUtility

CosturaUtility is a class that gives you access to initialize the Costura system manually in your own code. This is mainly for scenarios where the module initializer doesn't work, such as libraries and Mono.

To use, call CosturaUtility.Initialize() somewhere in your code, as early as possible.

class Program
{
    static Program()
    {
        CosturaUtility.Initialize();
    }

    static void Main(string[] args) { ... }
}

Unit Testing

Most unit test frameworks need the .dlls files in order to discover and perform the unit tests. You may need to add Costura and a configuration like the below to your testing assembly.

<Weavers>
    <Costura ExcludeAssemblies='TargetExe|TargetExeTest'
             CreateTemporaryAssemblies='true'
             DisableCleanup='true'/>
</Weavers>

Icon

Merge from The Noun Project

costura's People

Contributors

0xced avatar acecoderlaura avatar alex-davidson avatar arithmomaniac avatar augustoproiete avatar brunojuchli avatar cdagaming avatar danielchalmers avatar darvell avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dguder avatar distantcam avatar flcdrg avatar geertvanhorrik avatar github-actions[bot] avatar kbdavis07 avatar marcbarry avatar masters3d avatar maxxwyndham avatar petecooney avatar simoncropp avatar tom-englert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

costura's Issues

Costura embeds PropertyChanged, PropertyChanging libraries

Using Costura on a project that also uses PropertyChanged and PropertyChanging I found those assemblies were still embedded even though they are subsequently removed as references.

It didn't make a difference whether Costura was first or last in the list of Fody modules.

StackOverflowException - how to debug?

(Is this proper forum for this type of question?)

Costura was working quite nicely for me, but looks like I've done something it does not like. When I launch my application I'm receiving a StackOverflowException inside Costura.AssemblyLoader.ResolveAssembly.

I'm working with a Prism app (WPF), the exception occurs when I call my Bootstrapper.Run method, so I assume there is some problem with loading the Prism libraries

Any advice is appreciated to save time, maybe something simple you might know about.

Thanks

Nate

Krypton Controls Error

In trying to merge the Krypton controls from componentfactory.com, Costura seems to work fine as long as its running in visual studio. Outside of VS I get and error on startup:

System.NullReferenceException: Object reference not set to an instance of an object.
at Charts.Form1.ChartForm_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at ComponentFactory.Krypton.Toolkit.KryptonForm.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at ComponentFactory.Krypton.Toolkit.VisualForm.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

If I click continue it works fine from then on. Would controls be a special case because they load to soon in winforms to get picked up.

NuGet install script issues

I'm getting two issues when installing 0.2.1

  • The fody temp file is not being removed from the project.
  • The FodyWeaver.xml file is not being updated correctly.

I'm not really sure what the environment bits of the installer are doing, but they are what's screwing up the weaver file. As for the temp file the if check is not working correctly.

<Module> TypeInitializer KeyNotFoundException

I get the following exception if I start the application a second time:

bei .cctor()</StackTrace><ExceptionString>System.Collections.Generic.KeyNotFoundException: Der angegebene Schlüssel war nicht im Wörterbuch angegeben.
bei System.ThrowHelper.ThrowKeyNotFoundException()
bei System.Collections.Generic.Dictionary`2.get_Item(TKey key)
bei Costura.AssemblyLoader.InternalPreloadUnmanagedLibraries(String tempBasePath, IEnumerable`1 libs, Dictionary`2 checksums)

when I delete the %tmp%/Costura/[md5] folder everything works as expected

Version is 0.8.0.0

Localization selection

I'd like to include only one specific resource (one language). With the current behaviour all resources are included (I mean all languages available).

I am only interested on include one of them to save space. Is this possible?

Load issue in Mono

As reported by @phillip-haydon on Twitter.

Costura doesn't work with Sandra/Sandra.Snow on mono. CreateTemporaryAssemblies might be the culprit.

Remove un-used IL?

It would be good to be ale to remove un-used types and members from reference assemblies to minimise the deployment size of the resultant assembly.

Have the possibility to make sure that .Net won't load any (deprecated) dll located in the application folder

The application has been once deployed without using Costura and a reference assembly has been updated in the meantime. We now deploy our (fully managed code) application, thanks to costura, using a single .exe. Because we cannot delete the old dlls in the folder, costura cannot work correctly.

The problem that arise is that the .Net Framework doesn't give a chance for Costura to intervene, since AppDomain.AssemblyResolve isn't called, because it picks the existing dll in the application folder. Then, if the assembly has a strong name, it will throw an Exception because of version mismatch, and if not it will simply use the older version.

The application is autoupdated on system we don't have access to, and the autoupdater can't be extended to remove the old files.

If possible, I would like to contribute to this project by implementing the solution to this problem, however I failed at some attempts to solve it (tried this by doing what costura does manually without weaving). Any idea would be welcome.

Order of native and mixed mode assembly loading.

I have a native unmanaged DLL that is used by a mixed mode DLL. Unfortunately the mixed mode DLL loads first and unloads when it finds that the native DLL is missing. Then the native DLL loads properly.

Is there a way to reverse the order in Costura and force the native DLL to load first?

Decompression issues with other libraries

Just had a few problems decompressing Essential.Diagnostics (1.2.501.0) and Microsoft.Practices.EnterpriseLibrary.Logging (6.0.1304.0) with the newest version of Costura.Fody (0.6.0).

Had to revert to the previous version (0.5.3.0) in order for them to work.

Fody.Costura on Windows XP

Has there been any test of Costura on Windows XP, .net 4.0? I merged my application I have and tested on Windows Xp and it doesn't even register that it is an exe that can run properly.

Specify what assemblies get weaved

I have a feature request to abstract away some, not all external references. This means that I only want to weave specific assemblies with costura.

For example:

<costura>
    <includeAssemblies>
      <assembly Name="Catel.Core" />
    </includeAssemblies>
</costura>

When the "includeAssemblies" exists, all references are excluded by default.
When the "excludeAssemblies" exists, all references are included by default.

What do you think?

Costura must be loaded after NullGuard

This one stumped me for a good while.

Costura must be after NullGuard in the FodyWeavers.xml file. Otherwise NullGuard adds guards to the loader code that Costura adds, which breaks the loader.

Change resource name when compressed

ATM we embed the compressed files with the same file name as the uncompressed.
So the compressed resource name will be XXX.dll.
This is confusing for users who are trying to troubleshoot an issue. They could export a resource using a decompiler and expect to be able to then looking into that file. This will fail because it is actually compressed.

if we do this one #10 then perhaps the compressed resource names should be XXX.dll.zip???

Loading assembly twice

I've got 3 assemblies as follows:

  • Test framework (providers base classes for writing tests)
  • Examples (references framework; tests inherit from test base classes)
  • CommandLine tool (also references framework; allows to run the tests)

I'd like to use Costura for the command line to, so that it's only one physical file. Embedding the files works great, but when I initialize types located in the examples assembly, it loads the framework assembly again (AppDomain.CurrentDomain.GetAssemblies()). The problem does not occur if I don't use Costura.

Repro @ https://dl.dropboxusercontent.com/u/24549088/CosturaRepro.zip

Better debug support

  • [ ] Add support for patching an existing Costura.AssemblyLoader if it exists.
  • Investigate dumping the Costura.AssemblyLoader code into obj and putting the appropriate hooks into the pdb.

Costura for an SDK

I am having troubles getting it to work ATM.

I have this setup:

  1. SDK (Orchestra => https://github.com/Orcomp/Orchestra), uses costura
  2. Some app that only references a single assembly

In the app (no 2), I get issues that Fluent cannot be loaded. However this is available in the SDK (1), packaged by costura.

I expected this (in the SDK) to work:

public static void Attach()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyLoader.ResolveAssembly);
}

But it seems not?

Store the assembly names we expect

So at compile time we know the names of the files we embed. Both assemblies and debug symbols.

So instead of scanning all the resources at run time how about we compile in the list of expected files and corresponding resource names. perhaps some kind of hard coded static dictionary at the top of each ILTemplate??

@distantcam thoughts?

is it possible to use Costura for asp.net ?

Hello, in MVC4 project, after dll are merged. the following exception appears:

[HttpException]: Could not load type 'xxx.xxx.xxx.MvcApplication'.
at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)
at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)
at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)
[HttpParseException]: Could not load type 'xxx.xxx.xxx.MvcApplication'.
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
[HttpParseException]: Could not load type 'xxx.xxx.xxx.MvcApplication'.
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
[HttpException]: Could not load type 'xxx.xxx.xxx.MvcApplication'.
at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
[HttpException]: Could not load type 'xxx.xxx.xxx.MvcApplication'.
at System.Web.HttpRuntime.FirstRequestInit(HttpContext context)
at System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)

3 failing tests

currently we seem to have 3 failing tests. or at least we do on my machine

System.DllNotFoundException : Unable to load DLL 'AssemblyToReferenceNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at ClassToTest.SayHelloFromNative()
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1<T0,TRet>(CallSite site, T0 arg0)
   at InMemoryTests.Native() in InMemoryTests.cs: line 102

System.DllNotFoundException : Unable to load DLL 'AssemblyToReferenceMixed': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at ClassToTest.SayHelloFromMixed()
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1<T0,TRet>(CallSite site, T0 arg0)
   at InMemoryTests.MixedPInvoke() in InMemoryTests.cs: line 116

System.IO.FileNotFoundException : Could not load file or assembly 'AssemblyToReferenceMixed, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
   at ClassToTest.MixedFoo()
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1<T0,TRet>(CallSite site, T0 arg0)
   at InMemoryTests.Mixed() in InMemoryTests.cs: line 109

NullReferenceException in ReadExistingAssembly

In this code:

public static Assembly ReadExistingAssembly(AssemblyName name)
{
    var currentDomain = AppDomain.CurrentDomain;
    var assemblies = currentDomain.GetAssemblies();
    foreach (var assembly in assemblies)
    {
        var currentName = assembly.GetName();
        if (currentName.Name == name.Name && currentName.CultureInfo.Name == name.CultureInfo.Name)
        {
            return assembly;
        }
    }
    return null;
}

It is possible that name.CultureInfo == null. A fix is pretty easy:

if (string.Equals(currentName.Name, name.Name)
{
    if (name.CultureInfo == null || string.Equals(currentName.CultureInfo.Name, name.CultureInfo.Name))
    {
        return assembly;
    }
}

Cache Assemblies and native dlls in temp location to improve start time

It would be nice to have the option to cache assemblies to disk to save the decompression overhead on subsequent runs. Compression is a great feature but app startup times can be affected quite a bit. Would Temp or AppData be better?

Did I see that support for native dll's was added recently?

Costura doesn't remove assemblies from build folder

It would be nice if Costura removes the assemblies it embeds from the build folder.

That way the assembly won't accidentally load a reference from that folder.

I'm not sure how to do this. Maybe fody needs to be involved somehow?

Make CleanReferencesTask smarter

We can make the clean references task smarter by reading the fody config and parsing the exclusion list before remove the references.

A few points to consider.

  • Should the task be coded into an assembly, or directly into msbuild script. I don't think it'll take more than a handful of lines of C# to parse the fody xml.
  • Should the CleanReferencesTask be moved into it's own target file and then added to the project by NuGet?
  • Should the task be added automatically?

Costura not updating fodyweavers.xml correctly

I was installing it to an existing project which already had a few weavers. Then VS suddently asked me: do you want to overwrite FodyWeavers.xml?

It seemed that it created a brand new fodyweavers.xml instead of adding the weaver to the existing list of weavers.

UnauthorizedAccessException when calling CreateDirectory

This one is interesting because it works most of the time

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Runner' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.UnauthorizedAccessException: Access to the path 'C:\TeamCity\buildAgent\temp\buildTmp\Costura\4B39C0F01880E315F96B86C06E5758D3' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at Costura.AssemblyLoader.CreateDirectory() in :line 0
   at Costura.AssemblyLoader.Attach() in :line 0
   --- End of inner exception stack trace ---

Missing a using directive or an assembly reference

There is a problem with using StimulSoft report assemblies in a windows project.
It's thrown an Unhandled Exception with following error:
"The type or namespace name 'Stimulsoft' could not be found (are you missing a using directive or an assembly reference?)"
All of required assemblies are attached and program work fine when they are located in executable directory.
Required Assemblies:
Stimulsoft.Base.dll
Stimulsoft.Controls.dll
Stimulsoft.Controls.Win.dll
Stimulsoft.Report.dll
Stimulsoft.Report.Win.dll
Stimulsoft.Report.Wpf.dll

Question: How do you obtain the resource stream from a costura'd dll?

I am attemping to access one of the dll's that costura added to my wpf app's resources.
However, despite the name being in the list provided by Assembly.GetManifestResourceNames() I always get the exception that no resource could be found.

This is the name I am trying to use:

String assemblyResourceName = String.Format( "costura.{0}.zip", dllName.ToLower() )
Application.GetResourceStream(new Uri("pack://application:,,,/" + assemblyResourceName))

The resource is there (according to Assembly.GetManifestResourceNames()), just can't retrieve it. Anything else i need to do?

Exclude list for embedded resources

I see that all of the .pdb files are included as embedded resources by default. Is there a way to specify which files are excluded with a wildcard like *.pdb? I suspect this in the fody.targets file? Maybe this is just assumed from the build properties in the debug settings?

Compression

This features compresses the files before embedding them, and uncompresses them automatically right before use.

I've got this working in my own branch, but I'd still like to add a few features and discuss it before pushing to main.

  • Compressing of auto-embedded resources.
  • Updated loaders to read compressed resources.
  • Config option to turn off compression completely.
  • [ ] Config option to turn off compression per assembly.

NotACLSComplaintProperty C++

Getting the following error while installing Costura.Fody on an empty c++ CLR Project:

Attempting to resolve dependency 'Fody'.
Installing 'Fody 1.13.8.0'.
Successfully installed 'Fody 1.13.8.0'.
Installing 'Costura.Fody 0.3.2.1'.
Successfully installed 'Costura.Fody 0.3.2.1'.
Adding 'Fody 1.13.8.0' to Project3.
Successfully added 'Fody 1.13.8.0' to Project3.
Adding 'Costura.Fody 0.3.2.1' to Project3.
Successfully added 'Costura.Fody 0.3.2.1' to Project3.
Collection was modified; enumeration operation may not execute.
At \Project3\packages\Costura.Fody.0.3.2.1\Tools\install.ps1:6 char:11
+     Foreach ($item in $project.ProjectItems)
+              ~~~~~
    + CategoryInfo          : OperationStopped: (:) [], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException

The field/property: "project" for type:     "Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim" differs     only in case from the field/property: "Project". Failed to 
use non CLS compliant type.
At \Project3\packages\Costura.Fody.0.3.2.1\Tools\install.ps1:50 char:28
+     foreach ($reference in $project.Object.References)
+                            ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : NotACLSComplaintProperty

There is nothing in the current project and just updated to Visual 2012 Update 3.
Not sure if Costura.Fody gets properly installed...

Could not load file or assembly "System.Core, Version=2.0.5.0"

Scenario

  • Application references System.Core 4.0.0.0
  • Application references LibraryX
  • LibraryX references System.Core 2.0.5.0
  • Application attempts to load LibraryX

The following Exception can occur

{"Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. 
The system cannot find the file specified.": "System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes"}

The reason is that for the .net is incorrectly firing a AppDomain.AssemblyResolve for System.Core 2.0.5.0. This should not be happening since System.Core 2.0.5.0 should be automatically redirected to System.Core 4.0.0.0.

Strange Error On Build

Error 36 The "Fody.WeavingTask" task failed unexpectedly.
System.TypeInitializationException: The type initializer for 'ContainsTypeChecker' threw an exception. ---> System.InvalidCastException: Unable to cast transparent proxy to type 'IContainsTypeChecker'.
at ContainsTypeChecker..cctor() in c:\TeamCity\buildAgent\work\7495521761d392b9\Fody\ContainsTypeChecker.cs:line 15
--- End of inner exception stack trace ---
at ContainsTypeChecker..ctor()
at Processor..ctor() in c:\TeamCity\buildAgent\work\7495521761d392b9\Fody\Processor.cs:line 28
at Fody.WeavingTask.Execute() in c:\TeamCity\buildAgent\work\7495521761d392b9\Fody\WeavingTask.cs:line 44
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() CiDGETS_UnitTests

I'm getting this error after updating Costura this morning. Any ideas what this means?

32 and 64 bit unmanaged libraries keep swapping in temp folder

In a 64-bit app, when using the XAML designer it loads the assembly in the 32-bit context. So Costura saves the 32-bit version of unmanaged libs to the temp folder. Then when debugging the app in 64-bit Costura see's the 32-bit version, see's it's the wrong bit version and tries to replace it. Unfortunately the designer is still open so the 32-bit version cannot be moved or deleted.

The solution here is to have bit dependent versions of libs put into seperate 32 and 64 bit folders within the temp folder.

Enable assemblies to be loaded on command

I want to extract and load the assemblies on-demand. Now Costura intercepts the ResolveAssembly (or something like that) event and then extracts the assembly.

I want to be able to extract the resources on-demand.

Localization Support

This issue is to track supporting embedding localized assemblies into Costura.

Temp assembly cleanup

So, what do people think would be the best way to clean up temp assemblies?

Should we add a handler to AppDomain.ProcessExit to clean them up?

NuGet - install to all projects?

Quick question, is it your intention that Costura be installed to all projects, or is it necessary to only install in the main/exe project?

I'm up and running (it's great stuff, thank you!) - I installed to all projects (that was the NuGet default) but I'm wondering now if that was necessary. Not a problem, I suppose, other than having Fody.targets and FodyWeavers.xml files in each project. Would like to clean them up if not required.

[VisualStudio 2013 Pro, WPF, solution has one EXE project and six supporting class library/DLL projects]

Embedding a library that is an exe results in FileNotFoundException

An exe can be added as a project reference when you need to reuse some code from it. Costura correctly embeds the assembly (as "costura.sharedlibexe.exe.zip), but fails to resolve it when the parent exe runs.

Using v0.3.2.0.

Example solution at http://www.sendspace.com/file/bs6b9v
To replicate, build, move resulting StartupExe.exe out to a new folder, run, press a key, observe exception.

System.IO.FileNotFoundException was unhandled
  HResult=-2147024894
  Message=Could not load file or assembly 'SharedLibExe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
  Source=StartupExe
  FileName=SharedLibExe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  FusionLog==== Pre-bind state information ===
LOG: User = DOMAIN\me
LOG: DisplayName = SharedLibExe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/VS Projects/TestCostura/StartupExe/bin/
LOG: Initial PrivatePath = NULL
Calling assembly : StartupExe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

  StackTrace:
       at StartupExe.Program.GetValue()
       at StartupExe.Program.Main(String[] args)
  InnerException:

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.