getting an embedded resource in a single dll made up of multiple class libraries - dll

my solution has multiple projects and in one of them I have the code to get the embedded resource (an xml file) from another project. All this works fine when all the projects are seperate. However when all the class libraries are embedded into a single dll, the code to get the resource file does not work i.e. it cannot get the emebedded resource.
I was wondering if the references to the emebedded resource get mixed up when they are combined together in a single dll??
I use the method Assembly.GetCallingAssembly().GetManifestResourceStream("namespace..filename");

I would not use Assembly.GetCallingAssembly(). I would use typeof(SomeClassNextToXmlFile).Assembly that way if you are calling the dll with the embedded resource from a exe file it won't go looking in the exe for the resource. Also you may want to try using Reflector and make sure the resource you are looking for is where you think it is.

Related

How to register a Property Handler on folders?

I built a virtual filesystem (not a namespace extension) for Windows which acts as a frontend of our document management server consisting of files and folders. In order to be able to display some metadata of the DMS objects in Windows Explorer as additional selectable columns, I successfully provided properties to the Windows Property System by implementing a COM Property Handler. Wheras normal property handlers focus on specific file types for which they feel responsible, my Property Handler adds properties to all files regardless of their type. Because Property Handlers can only be registered on the file type level, I registered my handler for about 30 types under
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers\<.Extension>
However, I did not manage to register the Property Handler for folder objects. Since all objects in our file system are virtual I build the property store (IPropertyStore) by implementing IInitializeWithFile instead of IInitializeWithStream. The properties are requested from our DMS with the path of IInitializeWithFile acting as key and were not read from an objects content. This concept would work for folders as well.
For getting called on folders I tried to associate the handler by registering under different well known identifiers like Folder, Directory, AllFileSystemObjects and * instead of the file extension without success.
I also didn’t find anything in the MSDN documentation regarding this aspect.
Is there a way to register a Windows Property Handler on folders? Or is there some other way to add custom columns to folders in Windows Explorer?
I'm not sure if it is possible to do this.
Property handlers are clearly not the right approach, they are system wide and there can only be one per file extension. They should only be implemented by the software that "owns" the file extension and can parse the file to extract properties.
The old column handlers would have been your best bet (IMHO) but they are officially dead and you already said you can't use them.
Have you considered creating a namespace extension? Either as a root item somewhere (Desktop or My Computer) the way My Documents used to work in 2000/XP or maybe something more along the lines of how OneDrive works?
I'm not sure if desktop.ini files work in the root of a drive but it might be worth looking into. You would then find yourself in the poorly documented land of [.ShellClassInfo] and its CLSID, CLSID2 and UICLSID members. The general idea would be to act as a IShellFolder proxy on top of the "real" IShellFolder so you could create a multiplex property store. I think there are some (undocumented?) property keys you can override to change the folders default columns and tooltips as well.
There is also something called a delegated folder that allows you to play with nested PIDLs but the documentation is once again pretty useless so I'm not sure if this is something worth looking into.
A 3rd option is to pretend to be a cloud storage provider. I don't know if this gets you any closer to your goal and you would still have to implement some NSE bits to get to the point where you can layer yourself on top of the underlying IShellFolder. This feature is rather new and only documented to work on Windows 10.
The inner workings of how Explorer/IShellBrowser is connected to the IShellFolder/IShellView is one of the least documented parts of Windows. There are hundreds of undocumented interfaces. Explorer gives DefView special treatment leaving other 3rd-party implementations out in the cold.
My feeling is that there is no clean solution to implement this on top of a drive letter but you might get lucky, if Raymond Chen drops by he might have some tips for you...

<global namespace> contains definition for __ in multiple code generated files

I just can't get a handle on how to correct this one. It cropped up about a week ago, and I don't know what change I made could have caused this. We use SVN and I rolled back changes I made of possible culprits of these errors but I am still getting the following errors when I build my asp.net webforms project:
The namespace <global namespace> already contains a definition for 'TrxStatus'
The namespace <global namespace> already contains a definition for 'MessageStatusType'
These two errors are repeated 5 times (10 errors total) and the source files are code generated for the loads of webservices we have in the project.
The file names are App_Code.34kjg234jh1.cs (made up, but you get the idea) and at the top of each one it tells me where it is being generated from:
App_Code\App_WebReferences\SomeService\SomeWebService.wsdl
If I go into the .wsdl definition I believe they do all live in the same namespace based off of this line: (Note, I am not a .wsdl wiz, so tell me if I am wrong)
<s:schema elementFormDefault="qualified" targetNamespace="http://www.thirdpartysite.com/Soa/Foundation/">
<s:import namespace="http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd" />
This is an application inherited from our prior developer (its a one developer shop here, so I usually get to poke around in the dark) so I don't know why we have about 7 different web services in the application, all with that namespace definition and ALL with the offending 'TrxStatus' and 'MessageStatusType'.
I don't want to change the namespaces, because it is the right namespace (I believe), but I also need this conflict to go away. I am not sure which direction to go.
I attempted to go into one of the .wsdl files and change TrxStatus to TrxStatus_Whatever but that gave me this error:
Unable to import binding 'MyWebServiceName' from namespace http://www.thirdpartysite.com/SOA/Foundation
Another possible clue is I am getting a ton warnings from the various web services that say something like this:
The 'http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd:SomeElementName' element is not declared.
Any suggestions on possible solutions to this? What is the root cause? Please don't tell me I need to re-write all these services....
I'm by no measure an expert, in fact I do very little ASP.NET & Services.
BUT. It sounds as if there are conflicting imports (i.e usings) that are pulling in types with the same names.
proj1: A.SomeType
proj2: A.SomeType
You can add references to both projects and it play just fine (I believe). But the difficulty comes when you import both namespaces because the type names clash.
You can access the correct type by using the global:: accessor.
You can even use global:: in a using statement.
using A = global::[path to correct project and type here]
Not sure if it'll be much use to you, but there's more info on global:: here:
http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

Resource Files in CF - Not Embedded

I have a PPC2003 project in VS2005. I have added a resource file (SomeResources.resx) to the project. I can access the test string I have in the file by using My.Resources.SomeResources.MyTestString (I am using the default Custom Tool Name that VS provides).
When the Build Action property of the is set to Embedded Resource, the application references the MyTestString successfully.
But I do not want to embed the file, so that it's string values can be modified after it has been deployed/installed.
I, therefore, changed the Build Action to Content, so that the file gets copied out to the device for potential future manipulation. When I call MyTestString I get the following error:
MissingManifestResourceException Stack Trace: at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.GetString() at MyApp.My.Resources.SomeResources.get_MyTestString() at MyApp.fMain.fMain_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at MyApp.fMain.Main()
As the file is not embedded, do I maybe need to manually load it first? If so, how? Any other ideas? Is it not possible to do what I'm after achieving and should I just create my own XML file/reader?
Resources (resx files) are specifically designed to be compiled into the application. If you want it to be an editable content file on the target, then you have to approach it differently and use something like an XML file and wrap that with accessors (akin to the Configuration namespace stuff in the full framework).

Restlet static content served from multiple sources

My application needs to be able to serve up static content which can be contained in a number of different places (directories and/or via the class loader). So, for example, a resource /static/file.html might be found in /dir1/file.html or /dir2/file.html; I would want it to try /dir1, and if not found there, then /dir2, and so on.
With servlets in Jetty, I can use either a HandlerList of DefaultServlet, to sequentially try to handle the request from each directory until satisfied, or even easier a single DefaultServlet with a ResourceCollection.
I can't see a way to do something similar in restlet, without writing a class to specifically do this. I could modify Directory to handle multiple sources (in a similar way to DefaultServlet with ResourceCollection), or write a new Restlet which tries each contained Restlet sequentially, until successfully handled (like HandlerList). But before I do that, am I missing another way that already exists to achieve this?
thanks,
Stuart
I confirm that Directory doesn't know how to handle multiple source directories. It would be a nice to add support for this and contribute it back.

EntLib 5 Wrap Handler Message Localization

I have been asked, at very short notice of course, to implement exception logging to the Windows Application event Log in one of our products (vb.Net, framework 3.5, WinForms) using EntLib 5. In and of itself this is fine - I can get that working. However, this is for a client who wants messages in Chinese. Certain parts of the app have language resource files and I found a couple of sentences in my MS EntLib Developers Guide book which suggested that I could use an external resource to provide a localised 'friendly' message in a wrap handler within the Exception Handling Block.
Unfortunately there was no mention of how to actually achieve this but it seemed straightforward enough. I added a new resource to a resx file which lives at the project level for the project which is common to all areas of the application and re-built to project so that the satellite assemblies were built. I then specified the name of the resource in the 'Message Resource Name' field within the EntLib configuration console. the problem arises when I try and specify the 'Message Resource Type'.
I clicked on the search button and found the satellite assembly I needed, but it did not get added to the list of loaded assemblies and therefore I couldn't select it. The problem is that none of the places where I've seen this feature mentioned actually demonstrate how to get it working so I'm not sure where I'm going wrong. The search for the assembly will only let me select a dll or exe so I assume I am supposed to reference the satellite assembly somehow but how do I do this if it won't add it to the list of loaded assemblies?
One point to note is that we have a main executable which then calls numerous class libraries to load areas of functionality as required, and the config file we use throughout is the one which belongs to the main executable. Is it the case that you can only use satellite assemblies which are related to the assembly that the config file belongs to?
I haven't yet fully utilized this feature yet but just something to check, are you using the fully qualified name of the assembly?
EDIT: A potentially applicable link - http://entlib.codeplex.com/discussions/67460