Recover WinForms from dll - winforms

We think most of the source has been recovered through .NET Reflector. A utility which export the dll as C# source.
The only missing part is WinForms which is not included when .NET Reflector export the dll source.
Is there any way to get the WinForms recover from dll?
Thanks.

If it's not in the dll, you can't get it out :-)
But possible some class files are the forms you're searching for. Maybe you have to add a reference to System.Windows.Forms.dll to your project.

From Visual Studio 2005 on, Windows Forms classes are partial classes split into a Designer generated part (MyForm.designer.cs) and your actual implementation (MyForm.cs). You can see that in Explorer when you create a new Form from scratch.
In order to resolve your problem you would have to split up the class exported by Reflector the same way that Visual Studio does: Place the InitializeComponent() method and all control declarations into the MyForm.designer.cs file and the remaining code into the MyForm.cs file.

Related

How can I localize strings in Xaml files for WPFLocalizationExtension

I'm using WPFLocalizationExtension to localize my WPF application. I'm very happy with the run-time behavior, but extracting string properties manually to ResX files is very tedious.
Is there a way to automate this? I used to have a tool called Xaml Localizer Addin that did exactly this (screenshot below), but it only works with VS2008 and I couldn't find a newer version.
If you're using visual studio 2010, you may want to check out Xaml Localization Tool. It's an extension for vs2010 to localize xaml application, and generate .resx files from xaml.
Another idea is to download XAML Localize Source Code and build your own visual studio add-in or tool that is compatible with your version of .net.

Intillisense fails on undefined namespace in XAML on Visual Studio 2010

I must be brain dead. I have tried for six hours now (with Google) and can not solve this very very simple problem.
In Visual Studio 2010, I created a project. (right-click on solution, Add new project...).
Inside the new project, I created a new folder of name Helpers. To the folder I added a class for a converter.
Inside the project, I added a new XAML window (in WPF). The Target Framework is .Net Framework 4.0
Everything has been built (multiple times) without compilation errors. The platform target build for the project is X86.
The problem: Intellisense does not see the namespace for the class under the Helpers folder and so the Visual Designer fails. The namespace in the Helpers folder is:
Chaos.UI.Helpers
and trying to reference this namespace in the XAML like:
xmlns:converters="clr-namespace:Chaos.UI.Helpers"
ofcourse results in the dreaded:
Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'Chaos.UI.Helpers' that is not included in the assembly.
These are clean files in the same project. The only added code is in the converter class contained in the Chaos.UI.Helpers namespace.
How do I fix this? (I need the designer to work).
Anybody, Plz help
Try use assembly
xmlns:converters="clr-namespace:Chaos.UI.Helpers;assembly=Chaos.UI"

The tag "xxx" does not exist in XML namespace"yyy" / Reference could not be found

I have a winform usercontrol than I want to add to wpf project.
I added the relevant references (WindowsFormsIntegration, SystemWindowsForms and my user control dll) and added this row in my XAML:
xmlns:MyControl="clr-namespace:xx.xx.xx;assembly=xx.xx"
And then this:
<WindowsFormsHost><MyControl:control></MyControl:control></WindowsFormsHost>
When I write "MyControl:" the "control" is automated show up that mean VS recognize the control and all references added ok... but when I compile the project this give me the error in the title.
Edit
Its very strange when I'm compile the all project i've got error "The type or namespace name "xx' could not be found..."
but I added all the refernces and the VS recognize the namespace so why the compiler don't found them? If this problem will be solved I beleive the other problem also will disappear.
The solution is: Go to your project properties and change the Target Framework from Client Profile to the full version of the .Net you are using, see the image below. This problem happens if your DLL targets the full .NET Framework, and your WPF Application (main project) targets .Net Client Profile.
This happened to me when I included the assembly name in the namespace definition, but both controls were in the same assembly. Just removing the assembly part of the namespace declaration solved it.
Visual Studio will load the reference only for reflection so it will show correct intellisense correctly. But in order to compile, compiler will need all the dlls that your referenced dll is dependent on. So visual studio will show intellisense for mycontrol as it can find it in reference. But your myontrol may reference other dlls which you may not have added. You will have to add dependent references of mycontrol in your project too.
It could also be that the target framework is different between your projects. We host a class library dll with the WPF pages, and it was targeted to 'Any CPU', but the host application was targeted to 'x86'. Once they matched, the problem went away.
I ran into the same "The type or namespace name 'xx' could not be found..." issue.
It disappears when I moved my Visual Studio files on a local drive. They were stored on a shared network directory before. I dont know the root cause of this, but at least I can have my designer running now.
I've encountered this problem before and replacing <MyControl:control></MyControl:control> with just <MyControl:control/> fixed it for me.
No idea why though. It seems like the first form is only for controls which can contain other controls.

XAML in VS Shell: Loading an assembly without reference

I'm currently trying to customize a Visual Studio Isolated Shell so it opens a XAML file and its designer without a solution or a project. Therefore, for the designer to load, Visual Studio need to recognize every xaml tag in the XAML file or it won't load telling me that the document contains errors.
I'm currently trying to manually load an assembly from Telerik's control set (RadControls) without a reference since I need to use the designer without a solution/project.
Is it possible to manually load an assembly in XAML from a "custom" .dll like Telerik's without a VS project reference so the custom controls from the assembly are recognized by Visual Studio at design time (in order to use the WPF designer)?
Thanks!
SatixX
maybe you can read the namespace references out and try to resolve the assemblies in GAC and/or any other location (think of standard paths .NET itselfs looks for assemblies). Then try to load them with reflection. Afterwards you then could try to load the XAML. But: if an assembly isn't found, you should throw an error and stop loading the XAML. Also, considering an appdomain might be well suited because you can unload it again.
-sa

How to Import System.ServiceProcess namespace into WPF project? Not showing in CodeSense

how can I import the System.ServiceProcess namespace into a WPF project in VB.NET (not C#)? The ServiceController object is not in the toolbox in VS2008 and I can't seem to figure it out. Any ideas? If that particular namespace cannot be imported into WPF projects, could somebody suggest another way of controlling windows services from a WPF application? I know this framework is focused more on multimedia apps, but would really like to switch over some of my tools to WPF.
Thanks in advance!
You need to add a reference to System.ServiceProcess.dll.
The confusing thing is that this assembly is not in C:\Program Files\Reference Assemblies\Microsoft\Framework. It should be be in the GAC; however, it might not show in the list of assemblies. You can browse to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and reference it from there.
I assume you mean you want to add a project reference, rather than specifically adding it into a XAML file.
You will need to add a reference to the appropriate DLL, but it might be hidden from you if you aren't targeting the correct framework version -- make sure your project properties say you are targeting 3.5.
In my case, I used VS2017, I searched for System.ServiceProcess in NuGet manager (Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...)
Install it for the required projects and that is it.

Resources