|
I've loaded an assembly by reflection, and now wish to re-combile the resource it represents, before continuing my testing of it.
The problem i have is, once i load an assembly, it remains in use until i exit my application. I've closed all refferences to this assembly, and all types used by it have been disposed and garbage collected.
How would i go about unloading the assmebly completely from my application?
Cheers
Tris
|
|
|
|
|
Unloading of single assemblies is not possible. You can unload only at the AppDomain level, so a solution in your case could be loading your assembly in a separate appdomain and then unload it when it is no longer used.
For a better explanation on the reasons why you cannot unload single assemblies and alternative ways of doing it i suggest you
this
Bye!
|
|
|
|
|
Hi!
I'm trying to retrieve a value from a XML using XPath. However, I get this exception:
Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
My code is as following:
XPath Query: /rdf:RDF/geo:Point/geo:lat/text()
C# Code:
public static string GetValue(XPathDocument doc, string query) <br />
{<br />
XPathNavigator nav = doc.CreateNavigator(); <br />
XPathNodeIterator iter = nav.Select(query);<br />
<br />
if (iter.MoveNext()) <br />
return iter.Current.Value;<br />
else<br />
return null;<br />
}
XML:
<rdf:RDF xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<geo:Point>
<geo:long>-0.15</geo:long>
<geo:lat>50.8333333</geo:lat>
</geo:Point>
</rdf:RDF>
Anyone has an idea of what's going on? It must be pretty simple but I couldn't find much on Google.
Thanks!
|
|
|
|
|
You need to pass an instance of the XmlNamespaceManager to the function so that namespace prefixes can be resolved.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
How can I do this? I assume italicizing one word in the middle of a sentence is beyond the capabilities of a label object, but haven't been able to find a way to do it using a (crippled) richtextbox either.
|
|
|
|
|
First use the SelectionStart and SelectionLength properties of the control to select the part of the text you want to italicise, the go with this:
[RichTextBox].SelectionFont =
new System.Drawing.Font(
[RichTextBox].SelectionFont,
FontStyle.Italic);
Hope it helps.
|
|
|
|
|
That looks like it should work. I was trying to do it in the designer since it's a static string.
|
|
|
|
|
I'm looking to protect my application by hacker.
But i don't know how hackers work, so i asked you if is possible to get an embedded file from an .exe, and someone answered me yes.
Now i ask you, how?
If i set a bitmap file inside an exe what program or other way i can use to get the bitmap embedded?
I watched for the software reshack but it find just icons embedded.
|
|
|
|
|
If you haven't already you should look at Lutz Roeder's .NET Reflector (http://www.aisto.com/roeder/dotnet/[^]).
This excellent tool shows just how vulnerable your .NET assemblies are to hacking and reverse engineering - it will also show you what embedded resources you have in your assembly.
Rob Philpott.
|
|
|
|
|
so it is impossible to hide
|
|
|
|
|
Obfuscators will make it more difficult to reverse engineer. Nothing's perfect though, and native code is crackable by the determined as well. I wouldn't worry too much the people who steal apps generally won't buy a copy in any circumstance so you're not looking at real losses.
|
|
|
|
|
Did you try .NET reflector?
I'm probably not the best person to answer this question, but my current understanding is that the most common approach to protecting your code is to 'obfuscate' it - jumble it around a bit to make it hard for anything with less patience than a computer to understand. Take a look at http://www.preemptive.com/products/dotfuscator/index.html[^], as an example of one such tool.
There's plenty of companies touting their solutions on the web - have a look around.
As regards embedded resources - they've always been accessible in standard exes. In the old days you could open up an .exe with AppStudio and play around its resources direct - I don't know if you can still do this with Visual Studio. You could obfuscate this too I guess, using some simple encryption of your image which you decrypt at runtime.
I would seriously question whether .NET is the correct technology to use for anyone seriously concerned about their intellectual property.
Regards,
Rob Philpott.
|
|
|
|
|
Sh*t i havn't no idea it was so easy other get embedded resources but also the whole code!!!
These solution doesn't protect fully the code.
Is it possible to get the code in other ways?
Then do u think making a c++ pure application i've not problem like this?
|
|
|
|
|
ALL computer code is readily hackable and decompilable, it's just a matter of patience. It's very easy in .NET, even with obfuscated code, but much easier than people realize when using native C/C++. I've long ceased worrying about it.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I am wrting a .NET run-time compiler. It is fine if i compile a C# code using the following code :
Microsoft.CSharp.CSharpCodeProvider = new Microsoft.CSharp.CSharpCodeProvider ();
ICodeCompiler compiler = provider.CreateCompiler ();
CompilerParameters compilerparams = new CompilerParameters ();
CompilerResults results = compiler.CompileAssemblyFromSource(compilerparams, code);
the compiler run fine. But if i change the comipler to compile a VB.NET code as:
Microsoft.VisualBasic.VBCodeProvider provider = new Microsoft.VisualBasic.VBCodeProvider ();
ICodeCompiler compiler = provider.CreateCompiler ();
CompilerParameters compilerparams = new CompilerParameters ();
CompilerResults results = compiler.CompileAssemblyFromSource(compilerparams, code);
it is a error at the last line !!! what cause the problem ????
In fact, there are a serveral assembilies i wrote in C# in order to compiler the source code. Does this possibly cause the problem ? it sounds so strange !!!!
|
|
|
|
|
Tee+ wrote: it is a error at the last line !!! what cause the problem ????
Probably your code. An indication of the error you receive would be helpful.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Seems that it is not my code error:
System.IO.FileNotFoundException: Could not find file "C:\DOCUME~1\Vithan\LOCALS~1\Temp\srxzw0s0.dll".
File name: "C:\DOCUME~1\Vithan\LOCALS~1\Temp\srxzw0s0.dll"
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.CodeDom.Compiler.CodeCompiler.FromFileBatch(CompilerParameters options, String[] fileNames)
at System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters options, String source)
at System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSource(CompilerParameters options, String source)
at Utility.ActionScript.BuildAssembly(String code)
Please help.
|
|
|
|
|
Given CultureInfo object, how can i determine the text orientation of this culture?
For example, arabic and hebrew are written from right to left, some eastern languages are written from top to bottom and right to left and so on.
Thank in advanced, ilan
|
|
|
|
|
Hi
I need to ge the node that the user right clicked on. BAsed on information stored in the tag value I need to change the context menu before the user sees it.
How do I get this NodeItem. The node is not selected during a right click action so SelectedNode does not work.
I am using VS 2003. 2005 does a lot more with the addition of treeview.hittest but it is not an option for this project.
Any good ideas out there
tcss
|
|
|
|
|
Have a look at the GetNodeAt function of the TreeView. Use this in conjunction with the MouseDown or MouseUp event.
|
|
|
|
|
Hi
I'm trying to create a regex pattern to replace some text in a string, but am having problems with it. Basically, I need to replace a whole word only, but for some reason it's not matching the word if it's followed by an underscore, otherwise it works.
Eg. If the string looks like this:
SomeText,SomeMoreText
blah blah blah
SomeText_SomeMoreText
It'll only replace the first occurance.
This is what I'm using:
myString = Regex.Replace(myString, "\\bSomeText\\b", "NewText");
Thanks.
|
|
|
|
|
Guys,
How can I populate a hyperlink in VERTICAL in code behind using c#. I have a 20 links from the database, after retrieving it I want the data be place to hyperlink control for connection to another pages. I want it to happen during runtime and not in design time.
Somebody know any Idea? I tried to use the placeholder but it display horizontally no other option to display it vertically.
Thanks
/Dabuskol
|
|
|
|
|
The anchor tag is an inline tag, so if you have anchor tags after each other they will flow just like text. If you want them underneath each other you have to add html tags to place the anchor tags where you want them, for an example putting each anchor tag in a div tag.
---
b { font-weight: normal; }
|
|
|
|
|
Hi Everyone,
I am faced with a bit of a problem. I suspect it is a problem only because of my non-existant knowledge of c/c++.
I need to use a third party SDK to be able to control and/or monitor some telephony hardware from a popular vendor.
My problem is that I have to do this from a .Net environment (C#) but the SDK file are .lib files. It is said that it is dynamically compiled (what that means I have no idea).
Can anyone possibly tell me how I could use it from C# and if it's impossible, how I can wrap it in normal dll's (so I can use Dllimport) as normal.
Thanks and Regards,
Phi?
|
|
|
|
|
As far as I know there is no way to include .lib files in a C# assembly. Your assumption is right in that you have to write a quick wrapper for the .lib but there's good news: the wrapper doesn't necessarily have to be a native DLL. You could start a Managed C++ .NET Control Library project which will create a .NET assembly DLL that you would be able to reference from C#. Granted the task is not trivial if you have no experience writing C/C++ but you should be able to find some examples on the web on how to wrap a .lib in a managed assembly using Managed Extentions for C++.
Basically after you start the project you will have to do the follwing, in order to import the .lib:
In the project settings, look for Linker Options, additional include files and add your .lib file in that list (make sure to include the fully qualified path if the file doesn't reside in the project folder or in the windows folder). The next thing to do is to use #import "file_name.lib" in the header for you assembly. Doing that will make the content of the .lib accesible to your project and then you'll be able to start writing the wrapper functions. You don't have to write wrappers for all the functions in the .lib; only for those that you will be using. The part that will be a little more complex will be data marshalling between the native api and the managed assembly, but there's a ton of documentation out there on how to accomplish that.
Good luck!
|
|
|
|