Is there any tool available to read or explore the solution components using solution file?
OR
Is there any class in Microsoft Dynamics CRM 2011 SDK which take the solution zip file as input and then I can simply use its properties/methods to read/validate the contents and components of the solution file?
For validation, there are several schema files within the SDK, one of them being the CustomizationsSolution.xsd
http://www.microsoft.com/en-us/download/details.aspx?id=24004
For reading the web resources, you can look directly within the "WebResources" folder or by scanning the "solution.xml" file.
Both of these will require unzipping.
There is a SolutionPackager.Exe tool in the SDK that will take an exported solution file and expand it out to directory with all of its components in separate files. I don't believe it has a public interface to call from other code - you would have to read the contents of the directory it creates to discover and read each section.
The XML Schemas (as #Paul Way states above) are available in the SDK. If you build C# classes from these - using xsd.exe in VS - you could (after unzipping the file) load the XML into a strongly-typed classes. This would get you close to what you want - but not exactly.
You want to be able to call something similar to var solution = CRMSolutionTool.LoadPackage(#"mysolution.zip") and then execute a foreach (var item in solution.entities){}. Unfortunately, no one has built such a library at this time.
Related
I have created a formula for my application. I know that there are many decompilers to break my application, I want to call a class file from my server and save it in my destination path like C:\test\Formula.cs and call it from my exe file where it is located from
C:\Users\Administrator\Documents\Visual Studio 2008\Projects\WindowsFormsApplication8\WindowsFormsApplication8\bin\Debug\myApp.exe
Similarly, since you can read a text file like this:
StreamReader reader = new StreamReader("C:\\test.txt");
I want to read my class like this:
Class readerclass = new Class("C:\\test\\Formula.cs");
Any help is appreciated.
You can't do that. C# is a compiled language! You can't just pull the source down and try to run it. To do this you would have to compile it on-the-fly and read in the resulting assembly, etc. It would be a disaster.
Now if you had compiled assemblies hosted on the server, you could theoretically download them, load them with Assembly.LoadFrom() and then instantiate classes from that.
You have to either create a library project that contains the formula.cs (dll) or include/add this formula.cs file into your current project.
I need to set the Company field value for some Word/PDF documents. I am talking about the extended file properties (summary/author/title, etc.) you see under File Properties.
I know how to get them (by using shell32.dll class library). I assumed that I could also set them with the same class library, but it seems like writing extended properties is a little bit more difficult and shell32.dll doesn't allow that.
I found something about taglib-sharp, which seems to have an option to set extended properties, but I don't really understand how it works.
Add following NuGet packages to your project:
Microsoft.WindowsAPICodePack-Shell by Microsoft
Microsoft.WindowsAPICodePack-Core by Microsoft
Read and Write Properties
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
string filePath = #"C:\temp\example.docx";
var file = ShellFile.FromFilePath(filePath);
// Read and Write:
string[] oldAuthors = file.Properties.System.Author.Value;
string oldTitle = file.Properties.System.Title.Value;
file.Properties.System.Author.Value = new string[] { "Author #1", "Author #2" };
file.Properties.System.Title.Value = "Example Title";
// Alternate way to Write:
ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter();
propertyWriter.WriteProperty(SystemProperties.System.Author, new string[] { "Author" });
propertyWriter.Close();
Important:
The file must be a valid one, created by the specific assigned software. Every file type has specific extended file properties and not all of them are writable.
If you right-click a file on desktop and cannot edit a property, you wont be able to edit it in code too.
Example:
Create txt file on desktop, rename its extension to docx. You can't
edit its Author or Title property.
Open it with Word, edit and save
it. Now you can.
So just make sure to use some try catch
Further Topic:
MS Docs: Implementing Property Handlers
Ok here is answer to my own question, since I wasn't really able to find my answer in this forum, it could be useful for others.
Solution is to use dsofile.dll and OleDocumentPropertiesClass.
Here is MS article about dsofile.dll - Link
In this link, you can download dsofile.dll with some other files. But most probably, just like I did, you will face some weird problems that are hard to find a solution for.
1) After intalling dsofile.dll, you will need to register the class: oped cmd and navigate to c:\dsofile of to directory, where you have extracted your downloaded dsofile.dll. After that - write line regsvr32 dsofile.dll. You should get a messagebox saying that registeration was succesful. If not, most propably you don't have admin rights. You are going to need admin rights in case you want this to work.
2) After trying to use this class in your program, if you are using .NET 4.0 it is possible, that you will see error saying something like "class cannot be embedded ..."
Well, for that, right click on dsofile in references list, properties -> embed interop files -> set to FALSE.
3) How to use:
//creates new class of oledocumentproperties
var doc = new OleDocumentPropertiesClass();
//open your selected file
doc.Open(pathToFile, false, dsoFileOpenOptions.dsoOptionDefault);
//you can set properties with summaryproperties.nameOfProperty = value; for example
doc.SummaryProperties.Company = "lol";
doc.SummaryProperties.Author = "me";
//after making changes, you need to use this line to save them
doc.Save();
Windows Explorer (using shell32.dll) is able to display the extended properties because it understands a lot of different file formats and can parse these. However, to set an extended property you probably need a file format specific library. E.g. to set the author of an MP3 file file is very different compared to setting the author of an Office document. (Actually Windows Explorer allows you to set some extended properties on Office documents.)
The taglib-sharp only works with media files and is most likely not able to set extended properties of any other type of file.
What you need is a library or a tool you can automate to modify PDF files. You can try to google pdf sdk. If you also need to work with Word files you can use COM automation to automate Word. Depending on the Word file format used you may also be able to work directly with the file without having Word installed (XML being much easier than the old binary "streams" format).
To set properties, you could utilize Windows' Property System. It provides an interface for accessing the "Property Store Cache" (IPropertyStore) where you can read/set any file's properties (regardless of the format), and add your own custom properties (the c library propkey.h has a comprehensive list of all available properties; you can also find these using prop.exe). This is essentially creating a Property Handler that must be later registered to your file extension. It is officially unsupported in managed code, so you might either want to write your own wrapper or use c++ (since this is a c# tagged question).
If you're specifically asking for media properties, check out metadata handlers, which are essentially codecs that extract your properties from the file and also called by explorer by default if you register them correctly.
I need to create a resource file for a .net project (by hand) and compile it using the ResGen.exe tool provided by the .NET framework. I can't find any documentation for this. I need to write the resource file by hand because I'm in a situation where I don't want to download/buy extra tools (like VS) to generate this resource file, and also I feel more productive through the command-line (helps me understand how things really work).
So I need to write a resource file by hand to store an ICON in the executable and use it from within my program. I would also like to use this icon to represent my executable in Windows Explorer.
Any references would be great!
Visual C# Express Edition will do what you want for free. If nothing else you can download that, create the resource file and then use that as a subject for your admirable curiosity about 'how it really works'. This may also save you some time in manual experimentation to get it right the first time around.
These 2 links in conjunction provide information on using that tool to create and embed an icon file, it seems specific to C#. Of course i'm guessing at your full intention, let me know if this points you in the proper direction.
http://www.xtremedotnettalk.com/showthread.php?t=75449
specifically there is a post which states;
I think you should first create a *.resources-File from the Icon with the tool named "Resgen.exe"...
resgen App.ico App.ico.resources
the next step would be compiling...
csc /t:winexe /out:Keygen.exe /res:App.ico.resources /r:Crypto.dll /win32icon:App.ico Keygen.cs AssemblyInfo.cs
I'm sure you were here already.
http://msdn.microsoft.com/en-us/library/ccec7sz1(VS.80).aspx
You should check this link:
http://msdn.microsoft.com/en-us/library/ekyft91f.aspx
It explains what formatter is used and gives some code samples to generate one from code. You could then write a small wrapper app that you can call from the command line. No downloads needed!
I'm programming a fairly simple application which I want to cut to just one simple EXE file + some data storage (XML for example).
My question is regarding configuration files. Where to put those files? I saw a few applications that have just an EXE file (uTorrent, Media Player Classic - I can use them without any installation), but they store their config somewhere else. How to achieve this?
How would you approach such situation? Is it better to try to achieve the thing I described above, or simply use a configuration file and data storage in the same directory as the EXE file?
Creating or using a file in the same folder (or in the App_Data) is pretty standard practice.
You use an installer like Inno Setup (free) to create a single exe installer (http://www.jrsoftware.org/isinfo.php)
If you want a DB rather than XML, have a look at SQLite (http://www.sqlite.org/) a file based DB or use an MS Access DB.
I think you want to take a look at Application Settings. This is an API which allows you to save user or application settings using a strongly typed API. Under the hood the settings are stored via XML serialization.
This API works with virtually every type of .Net application including low permission Click Once versions. It does the work of finding the place on disk appropriate for storing the data and completely hides it from you. It also has a nice GUI integration into Visual Studio.
EXE-only programs store their data either in the Windows Registry or in the user's Application Data/AppData folder. Although this may appear cleaner at first, it just hides the ugliness of scattering all your data around. I would suggest just going with a simple XML/INI/text data file that is generated when needed and easy to migrate.
Please see: WPF/C#: Where should I be saving user preferences files?
You could use the app.config file for storing your configuration. For the data, I would sugest something like db4o or SQLite.
Edit
This tutorial can show you how simple is to use db40 to store and retrieve your data.
Do not forget Isolated Storage. It gives you a place to read and write files to without the need for you to specify a location. Sometimes it is the only way sandboxed applications (like Silverlight) can store user or machine specific data locally. See here for an example.
I would store them in the same directory. That just seems easier to me, at least that's the way I always do it.
Is there a standard way in .Net to access and modify the windows services file? Right now I'm just accessing the file via a stream and writing to the file like I would for any other file. The file is located in c:\windows\system32\drivers\etc\, but I'm worried that this may change in 64 bit versions of Windows or may vary in different versions of Windows (I could be wrong and admittedly, I haven't looked into this very much yet). Aside from that, I'm just wondering if there is a standard way, say via WMI and/or the System.Management namespace, to find and modify the services file.
The actual specifics of what I need to do is to check if certain database aliases used for our software are specified for the expected ports. If not, add them.
An open source project called System.Peppers has a class doing this.
There is a registry key that contains the full path to the files you are editing.
Here is a link to the exact class: HostFile class
Use the System.Management.Instrumentation namespace
Sample code here
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=114
you can use System.Environment.SystemDirectory to get to the sys32 folder