|
theRealCondor wrote:
First of all: I have implemented LeppieRules in all of my own system variables, so I feel fine in asking this.
You are using it wrong!
OK, over to the series stuff!
theRealCondor wrote:
What I want to do is build a collection of each DLL that is to be included as references for my compiled code. I also want to make it version independant. So I thought that I could use Reflection to say "Here is the name space System" -or- "Here is the dll System.dll" then have Reflection give me that path construct to get to the System.dll location. I think this is possible via Reflection, but I keep getting lost in it when I try to find the component that can give me this answer.
Any suggestions on where to begin my easter egg hunt?
Start looking for an egg and not a bunny! What on earth are you trying to do? Reflection can only be used on compiled assemblies. Need more info, BUFFERUNDERUN EXCEPTION HALT!
PS: give me a code snippet of what you are trying to get
DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET low popularity, please visit
|
|
|
|
|
leppie wrote:
What on earth are you trying to do?
Michael wryly smiles as he slowly types out the answer:
Okay...what I am trying to do is build a list of project references to make my code compile correctly from the instance of the managed C# compiler. The references are to system.dll, system.data.dll, and system.xml.dll. (Maybe you begin to see a hint of potential problems here)
Now I can take the obviously simplistic approach which is to build a string array with hard coded directory locations for each dll. But that thought makes me want to stick my finger down my throat. It also locks my code into version 1.0.3705 of the framework. (part of the directory structure name) It would also lock me into either a machine with C:\WINNT or C:\WINDOWS as the system directory name for locating system.dll.
So the obvious next step is to get very generic by having my code say " Where is the assembly for System? " " Where is the assembly for System.XML?" or even " Where is the assembly for system.dll?". That way if my wizard runs on a machine with 1.0.3705 it will find the current version of system.dll compile the code correctly, AND when someone runs my wizard on a machine with 1.1.0000 then it too will find the current version of system.dll and compile correctly as well!!!!!
whew --- so that is the off-the-wall thing I am trying to do. End result is so cool you would not believe it.
We take a complex XML file, build a compressed schema of the file, run that through a SchemaToXML transform (our developed transform) that expresses all parts of the XML file as objects, then we do three transforms to create object.cs, reader.cs, and writer.cs. The final step is those three files get compiled into a dll and VOILA --- you now have an object model representation of that complex XML file for locating data, reading data, and updating data. In our case, that complex XML file is a fully externalized set of business rules that control parts of our application code. From a coders' viewpoint, accessing that xml file is no different that doing a "SELECT where TYPE = 'funky'" and getting back a collection of entries from the XML file that matches that type.
I'm writing the wizard that makes that whole build process an automated generation for any XML file fed to it, complete to the compiled DLL.
That is as long as I can systematically get the path name of the three system DLL's. I also tried exploring the File object to see if it exposed a FindFile method but that did not pan out either. I keep coming back to reflection, since it is dealing with known DLL's and it should be able to provide me with the assembly information that includes pathname. (After all, the assembly info when you Create Reference includes the full pathname!!!)
<publicnameexposed> Michael
Thanks for ANY help you can provide!
Condor
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
theRealCondor wrote:
That is as long as I can systematically get the path name of the three system DLL's. I also tried exploring the File object to see if it exposed a FindFile method but that did not pan out either. I keep coming back to reflection, since it is dealing with known DLL's and it should be able to provide me with the assembly information that includes pathname. (After all, the assembly info when you Create Reference includes the full pathname!!!)
I would suggest using CodeDom 's compilers instead. Like this:
CompilerParameters pars = new CompilerParameters();
pars.ReferencedAssemblies.Add("System.dll");
pars.ReferencedAssemblies.Add("System.Data.dll");
pars.ReferencedAssemblies.Add("System.Xml.dll");
CompilerResults res = new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler().CompileAssemblyFromFileBatch(
pars, new String[]{"one.cs","two.cs","three.cs"});
Now you have a ReferencedAssemblies collection, also I STILL dont understand why you wanna do this. AFAIK your assembly can ONLY use the framework version its been built on or newer (why would you ever want to use something older if you have something newer? Answer: dont install newer framework then!).
theRealCondor wrote:
That way if my wizard runs on a machine with 1.0.3705 it will find the current version of system.dll compile the code correctly, AND when someone runs my wizard on a machine with 1.1.0000 then it too will find the current version of system.dll and compile correctly as well!!!!!
As above, this will be (AFAIK) the default behaviour. I have used my above method without having to specify a path to it....with NO problems.
Hope this helps
DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you
|
|
|
|
|
Thanks. I am using the CodeDOM compiler....in my version of the Framework it is called the C# Managed Compiler.
So close and so far. I was looking at the ReferencedAssemblies but it shows it taking a string[] value that I assumed I had to build by hand. I never looked beyond it to see that it had an Add method. I put it together as you suggested and it works just great.
I think you misunderstood me, I DO want to most current version...I did not want an older version and I do not want to be locked into any given version. I also was unaware of the fact that providing just a dll name like that would actually find the dll.
Thanks much it helped tremendously. I now have a dll in my bin directory!!!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Quote from above:Thanks. I am using the CodeDOM compiler....in my version of the Framework it is called the C# Managed Compiler.
There are to 2 different ways to compile. Either like you have done, or the way I have shown above. I prefer my way as you can emit generated code as well.
DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you
|
|
|
|
|
leppie wrote:
DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET
Heh Heh --- so great minds think alike! Your wrapper process looks like the SQL Server version of what I'm building for XML files.
Once again, I must implement the method call:
developer.LeppieRules
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hi all,
Here's a quick question that has been bugging me for a while.
All I want to do is implement a ReplaceColor function for a given bitmap. I have written a simple version in GDI+ using ImageAttributes, ColorMap and Graphics.DrawImage, which works ok. It replaces a given rgb value with a new rgb value.
What I really want to do is include a threshold value. For example, if I had a bitmap of a red square gradient from red (255, 0, 0) to white (255, 255, 255). If the theshold value was high enough and the find colour was red (255, 0, 0) and the replace color was blue (0, 0, 255). The result would be a blue square gradient from blue (0, 0, 255) to white (255, 255, 255).
Any ideas? Is there a built in GDI+ method for doing this or would I need to write my own? I've seen the SetThreshold method of ImageAttributes, can I use this?
Thanks in advance
Andy
|
|
|
|
|
I dont think this is possible to do.
Just because the image is gradient of red and white, doesnt mean that only two colors are used. There can be many more (off white, light pink, dark pink...etc)
|
|
|
|
|
how can I realize a simple syntax highlightning richTextBox?
thanks
|
|
|
|
|
Your question implies that you are expecting a simple example that demonstrates how to implement syntax highlighting. Though not an impossible task, syntax highlighting is not a trivial one. I would start with Jan van den Baard's Brainchild and see if you can take what you learn there and port it to C#. There are others who have done this as well. I would just do a web search if Jan van den Baard's article and code doesn't help you.
Good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Is it possible to impersonate the caller of a method that is remoted? I have a remote component (which currently I'm planning to always run on the same machine as the client) that is hosted by a Windows Service. I want to run the service as LocalSystem yet impersonate the client user for some sections of code. Is this possible? Does it require COM+ and does that affect remoting?
|
|
|
|
|
Hey there guys,
I am trying to write a checkbox from the ground up. My problem is I want the box to be drawn vertically level with the baseline of the font (Baseline being where the Underline is drawn - just to clarify ). Does anyone know if there is a way to find for a given font where the base line lays?
Thanks,
()####CYBEROPPY=============>
|
|
|
|
|
Here's a scenerio. You all know those AIM chat windows? Say I want to write a C# winform that'll "eat" the chat window. The idea being I can take lots of AIM chat windows and put them all in the same form. (reduce taskbar clutter . . .)
I know this has been done in programs before, but they're all shareware and bloated. Obviously, I can do better. Plus, I won't learn anything.
So, any ideas? From what I've read, this will involve getting window handles via the win32 api. but this is new stuff to me. anybody have any ideas as how this would be done? tutorials on obtaining and manipulating window handles in C#? or any of you guys want to give me a quick tutorial?
Thanks,
-Alex
|
|
|
|
|
If I set Panel.AutoScrollPosition=blah blah blah right after the control is created, the scrollbars don't budge. But if I set the property as part of the OnPaint, they work fine. What's going on? All I'm trying to do is center the scrollbars when the control is created. I don't want to code a one-time "if" statement in the OnPaint!
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator.
|
|
|
|
|
Marc Clifton wrote:
I don't want to code a one-time "if" statement in the OnPaint!
Its only another if, yeah I hate them too, but thats what they there for! Unless you can do a switch perhaps?..
Cheers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
We have a manual process today where we do the following steps:
Take an XML file and create its' schema using XMLSpy.
We take the schema and treat this as a file-by-example and apply a transform against this file to create an object definition file. (which eventually runs through my wizard to create all the class libraries to access and update the original XML file)
I coding the frontend of the wizard mentioned above to transform the XSD file into our object definition file. In the framework all of the overloads for doing an XSLT transform put the document either through an XML Reader or starts with an XML Document -- which causes an XSD file to fail because it executes an XML validator. The transform method does not let me take in the XSD file as input and no overload supports taking an XSD file as input!!!!
Does ANYONE have a suggestion on how to execute an XSLT transform against a schema file!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
....just an added piece of input:
if anyone even knows how to invoke an xml.Transform() call with the xml validator turned off even THAT may get me past this problem!!
Thanks.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
This should be an easy question. I have a pointer to memory (a DIB), and I'm wanting to copy that memory to a Bitmap.
So, the second to the last line needs to copy from a IntPtr to an IntPtr. Problem is that Marshal.Copy will convert anything to a IntPtr, or an IntPtr to anything, but it won't copy from an IntPtr to an IntPtr.
So, how are you supposed to copy from one pointer to another?
Thanks!! Rectangle rcImage = new Rectangle( 0, 0, iWidth, iHeight );
m_CurrentImage = new Bitmap( iWidth, iHeight, PixelFormat.Format8bppIndexed );
BitmapData pBitmapData = m_CurrentImage.LockBits( rcImage, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed );
Marshal.Copy( hDibBitmap, pBitmapData.Scan0, 0, iWidth * iHeight );
m_CurrentImage.UnlockBits( pBitmapData );
|
|
|
|
|
psdavis wrote:
So, the second to the last line needs to copy from a IntPtr to an IntPtr. Problem is that Marshal.Copy will convert anything to a IntPtr, or an IntPtr to anything, but it won't copy from an IntPtr to an IntPtr.
So, how are you supposed to copy from one pointer to another?
Why on earth do you wanna do that? Why not just use the pointer?
OK I see what you are trying to do...perhaps Marshalling is NOT what need. Also you lock the memory as ReadOnly, then try to copy to it.... something strange! I have not worked with this before but AFAI can see you mite need to use ImageLockMode.UserInputBuffer...
Cheers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
Because Microsoft told me to!!
In general, you may take the following steps to create a Bitmap from a DIB with GDI+:<br />
<br />
1. Create a Bitmap<br />
2. Lock a rectangular portion of this bitmap and provide a temporary buffer <br />
via the LockBits method<br />
3. Copy the memory from DIB<br />
4. Unlock the Bitmap<br />
<br />
-- Microsoft Pseudo-Tech Support
I've read about 20 posts on how to create a Bitmap from the old traditional DIB and they always say about the same thing. My application is trying to convert a Twain DIB to a bitmap without saving/loading the image.
And you were right about the ReadOnly flag. I hadn't gotten it to compile enough to test it.
A lot of people are apparently having the same issue with the TWAIN support. .NET Twain Image Scanner
|
|
|
|
|
Sounds to me like you want to use the InteropServices and DllImport the CopyMemory function (from Kernel32.dll I think).
John :D
|
|
|
|
|
DOH!!! I am so nearsighted on the issue, I keep forgetting you can access the API directly.
I was so concentrating on trying to get Marshal to work since it has like 28 friggin overrides.
Thanks John!
|
|
|
|
|
John Fisher wrote:
Sounds to me like you want to use the InteropServices and DllImport the CopyMemory function (from Kernel32.dll I think).
Grr, I was just gonna sugest that! But his reply gave me a hunch to fix a small problem I have had for a long time
Cheers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
Well, if it makes you feel any better leppie, no success yet.
On the 'CopyMemory' step, getting 'object reference not set to an instance of an object' and no clues atm.
[DllImport("kernel32.dll", EntryPoint="RtlMoveMemory")]<br />
internal static extern void CopyMemory( IntPtr Destination, IntPtr Source, int Length );<br />
<br />
.....<br />
<br />
Rectangle rcImage = new Rectangle( 0, 0, iWidth, iHeight );<br />
<br />
m_CurrentImage = new Bitmap( iWidth, iHeight, PixelFormat.Format8bppIndexed );<br />
<br />
BitmapData pBitmapData = m_CurrentImage.LockBits( rcImage, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed );<br />
<br />
CopyMemory( pBitmapData.Scan0, hDibBitmap, iWidth * iHeight );<br />
<br />
m_CurrentImage.UnlockBits( pBitmapData );
|
|
|
|
|
Finally have some success. Thanks guys!!
I just needed to Lock my source pointer and it's working 'ok' at this time. Still gotta flip the memory upside down and ignore the headers.
|
|
|
|
|