Mono.Addins: Can a main app register an extension whose extension point is registered by another app? - mono.addins

I have the following scenario:
Common Project
Registers a few extension points (all interfaces) Have a public
Extension manager class which gives back registered extensions
Library Project
Registered as addin root Registers an extension whose extension point
is registered by Common Project Registers an extension point
Has an extension manager which gives back extensions registered to the
extension point above
Queries Common project to retrieve extension of one type and gets nothing (Extension is registered by main app, haven't tried putting a copy of exe in addins directory)
Main Application (exe)
Registered ass addin root Registers an extension whose extension point is in Common Project
Queries an extension where both extension point and extension are registered in Library Project.
Succeeds to get extension only when Library.dll is in ./addins directory.
My questions are
Can't we have a separate project that only registers extension
points and have other assemblies including the main app
export/register extensions to those points?
Are we supposed to keep all extension points in Main application or
some addin root? What if extension developers ship their extensions
that reference outdated version of our main assemblies that register
the points?

Related

WPF .NET Core 3.1 published self contained single exe missing DLL

Have a WPF .NET Core 3.1 app, and it was working on a computer for a while, then it would stop opening. Looking at the event viewer saw this error:
Description: A .NET Core application failed.
Application: MyApp.exe
Path: C:\Folder\MayApp.exe
Message: The application to execute does not exist: 'C:\Users\user\AppData\Local\Temp.net\MyApp\002t0akn.2dd\MyApp.dll'.
If you delete the folder and start the app again it works. Any idea why?
The app is published, .netcoreapp3.1, self-contained, win-86, produce a single file and ready to run
The NET Core "single file" mechanism is a lot like the self-extracting ZIP executables of old; it makes it easier to distribute, but it still needs to dump all of the dependent files out somewhere before it can run, and it looks like the specific temp folder may be giving you issues.
The process is described in Microsoft's documentation:
Extraction Location
For a single-file app, the extraction directory is <base>/<app>/<bundle-id>
<base> is
DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable, if set.
If not, defaults to:
Windows: %TEMP%\.net
<app> is the name of the single-exe binary
<bundle-id> is a unique Bundle-identifier.
You might try either disabling the single-file packaging or adjusting the environment variable to use a less transient folder for extraction.

How Settings.Default work for multiple applications accessing same dll

I have two applications refering to a dll (A.dll). The dlls are refernced from both application's local directories. Application1 use Settings.Default to store string to the dll (A.dll). Will those strigs that are saved to settings of A.Dll by Applciation1 be accessible to Application2?
As far as I'm aware, each application setting should have it's own settings file. Furthermore, if you have used a user-scoped settings, then each user from each application will have their own settings files.
You can find full details from the following links:
Using Settings in C#
Application Settings Overview

Silverlight fails to fetch resource assemblies

We use the .NET resource manager to localize our Silverlight application and want to embed the satellite assemblies for the german language ("de") into the XAP file. Therefor, we set the neutral language to "en" and added "de" to the list of supported languages in the csproj file. This works fine, when we build the project locally. If we build the Silverlight solution with MSBuild (TFS), Silverlight will try to fetch the satellite assemblies with HTTP requests from /ClientBin/de/*.dll instead of taking those files embeded into the XAP (which do exist). Because the webserver returns 404 error codes for the non existent files, Silverlight crashes with an initialization error.
It turned out that if we remove a custom TFS build activity manipulating the assembly info code files, the Silverlight applications works as expected. Strangely, after re-enabling the activity the compiled XAP application still works (verified for two different build definitions working on seperate branches). The custom activity manipulates the assembly attributes AssemblyConfiguration, AssemblyCompany, AssemblyProduct, AssemblyCopyright, AssemblyTrademark, AssemblyVersion, and AssemblyFileVersion.
Some additional hints:
The custom activity will change the assembly info files before any compilation is done
Compiling the manipulated sources with Visual Studio will build a working XAP
The content of the XAP files (working and not working) is equal (nearly same sizes, no difference in manifest file)
The resource manager is instantiated using ResourceManager("Resource", Assembly.GetExecutingAssembly())
My questions are:
Why does Silverlight try to fetch those satellite assemblies from /ClientBin/de/ instead of just using those in the XAP file?
What kind of attribute in the assembly info file could cause such a behavior?
Why does re-enabling the versioning activity not break the XAP again?
And here's the solution: We use a tool named "Total Commander" for editing a file in the generated XAP to adjust the URL the (generic) client connects to. Since we added the localization dlls, editing the XAP with the Total Commander will lead to the behavior described above. If we manipulate the XAP with WinRAR or the internal Windows archive manager, all works as expected.
Edit: After comparing the XAP files we found, that Total Commander uses the backslash (\) to seperate directories, whereas WinRAR and the Silverlight Tools use slashes (/). It seems that we discovered a hidden Silverlight feature here ;-)

ILMerging Windows Forms application with couple localizations problem

I've created a Windows Forms (C#) application called "Image Processing". It uses many external dlls so I decided to use ILMerge to merge all of them into one exe file and it worked. But today I've localized my application. After building I had 3 new folders in Debug folder: "en-US", "ru-RU", "uk-UA" with one dll with the same name "ImageProcessing.resources.dll". So I included all of them in a ILMerge command:
ILMerge.exe /t:winexe /out:ImageProcessingRelease.exe ImageProcessing.exe AForge.dll AForge.Imaging.dll AForge.Math.dll DevExpress.Data.v10.2.dll DevExpress.Utils.v10.2.dll DevExpress.XtraBars.v10.2.dll DevExpress.XtraEditors.v10.2.dll FreeImageNET.dll uk-UA\ImageProcessing.resources.dll ru-RU\ImageProcessing.resources.dll en-US\ImageProcessing.resources.dll
My program stores language locale in settings. After merging I can't change language, but settings are changing.
I don't know what else I can include here for more details so tell me please what.
The answer is simple. ILMerge is not suitable in this case, as .NET Framework relies on the folder structure to determine which resource file to use.
It is meaningless to combine assemblies in that way, and some third party assembly vendor's end user license does not permit you to merge their product with your own assemblies.

EXE generated in obj\Debug folder

I have inherited a Windows Forms application and I have found that a .EXE file gets generated into the obj\Debug folder everytime I compile.
I am more a Web Forms kind of developer so I am a little confused as to what is happening here. Why is it a .EXE and not a .DLL? What does this file actually represent? Is this the default behaviour for Windows Forms applications? Or, did my predecessor have to set it up up somehow?
As far as I can tell, the solution does not have a deployment project.
Their are many types of win application in delhpi. If u create windows form, .exe will be craeted in the debug folder similarly if you are creating Dynamic Link Liberary (DLL) .dll files will b created. These files are created each time when you compile the application.
Why this is a problem? Console application projects have exe file in the obj/Debug folder too. The obj folders are NOT used for running the application - they are used for creating the end binaries in the bin folders.
If the question is about exe vs dll then compiled exe file is used to run the application. In the web environment you used dll because ASP.NET new how to run code from it. But Windows knows how to run exe files, so any of your code actually can be compiled to an executable.
Every application be it web or windows would have an entry-point for execution. Anything in compiled form in .Net is an assembly which need not always be a DLL file. An EXE file is a .Net assembly with an entry point and few headers in the beginning of the file that identifies itself as a stand-alone executable to the windows operating system. In case of your web-application your asp.net pages are the entry points that users would type in a browser and start the application. In case of a stand-alone windows forms desktop application, it is an EXECUTABLE file, which user can click on run.
I am more a Web Forms kind of developer so I am a little confused as to what is happening here. Why is it a .EXE and not a .DLL?
Having said this, It is also important to note that, just like the asp.net is not the only platform to develop web-applications [you have php, jsp, etc.], .Net windows forms is also not the only way to create stand-alone executables. You can make EXEs in C, C++, VB, Delhpi, etc. only difference would be that they will not be .Net assemblies but all of them including .Net executables will have an entry-point to start execution from and the EXE header that identifies them as executables on the host windows operating system.
Why would it be a DLL? It's an application - it has to be launchable, unlike a website which lives "inside" a web server (effectively). The exe file is the application (along with any libraries it requires, of course). You double-click on it, it will launch the application. No problem.
Having said that, you should pretty much ignore the obj directory - it's just an intermediate directory. The bin directory is the one you should be taking build results from.

Resources