|
Hello all,
I'm doing a project that does a lot of dynamic inspection of assemblies. Does anyone know of a quick, clean way to save a reference to an assembly within code? In other words, I need some way to persist the information required to locate an assembly so I can load it again later. It's easy enough when it is in the GAC, but what do I do when I want to allow the user to load an assembly from a configurable directory. Any thoughts?
Thanks,
Will
|
|
|
|
|
I think you can do System.IO.Path.GetDirectory(assembly.Location), and then determine the relative path of the file to the configurable directory. You'd probably have to write some code to walk through the subdirectories.
So if the directory is c:\someapp\assemblies and you have an assembly in c:\someapp\assemblies\mammals\dog.dll, the reference would be recorded as mammals\dog.dll.
Just an idea.
|
|
|
|
|
Ok, I've searched my MSDN documentation, but to no avail.
I seem to remember from a different language (whether from C++ or Java, I'm not sure, but I'm leaning toward Java) that, with a two-dimensional array, I could initialize one row at a time, kinda sorta like this:
<br />
someType[][] arrayName = new someType[#][#];<br />
arrayName[0] = new someType[#];<br />
(note syntax of second line!)
Is there a way, in C#, to handle one ROW of a two-dimensional array (as if it were a single-dimensional array)?
I'm aware that the [][] syntax isn't used in C# (I'm aware of the fact that C# instead uses commas in one set of []). But, you get what I'm saying, right?
-Daniel
Typing too fast fro my owngood
-- modified at 16:49 Friday 19th May, 2006
|
|
|
|
|
The [][] syntax is used in C# to create a jagged array (where each sub-array can have a different length). It sounds like that is what you should use.
Josh
|
|
|
|
|
Really? I'll try it again. Thanks!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
I've created a CharArray that includes alpha characters and Numbers.
For Example the array might look like this:
[a][b][c][1][2][3]
I want to be able to check if each array is a character or an integer. If it's a character I want to assign it an equivelent number I assign.
For example in the first case of [a] I want to check if it's a character. Since it is, I want to assign a's with the number 1. So it will replace [a] with [1]. If it later checks [2] I want it to see that it's an integer and to leave the value at [2].
So my end result might look like this:
[1][2][3][1][2][3]
Any help on this would be appreciated. Sorry for the "noob" questions I have been posting but I am trying to learn Thanks!
|
|
|
|
|
I would recommend using Int32.TryParse (if you don't want to use Int32.Parse with a try/catch block). That's how I'd do it.
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
TryParse is only available in 2.0 (OP didn't specify whether which version they are using).
Since you're only dealing with single characters, the way I'd do it is to use char.IsDigit and char.IsApha to determine if you're dealing an integer or a character, then do the appropriate conversion.
-----
In the land of the blind, the one eyed man is king.
-- modified at 17:01 Friday 19th May, 2006
|
|
|
|
|
The simplest form of the code.
public class Service : System.Web.Services.WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public string PrintXML()
{
// Create a WebBrowser instance.
WebBrowser webBrowserForPrinting = new WebBrowser();
return "Success";
}
}
Hello world works ok.
PrintXML fails with an exception of the form:
System.Threading.ThreadStateException: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
at System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
at System.Windows.Forms.WebBrowser..ctor()
at Service.PrintXML()
Can anyone give me hints on what to do with this?
I've tried using attribute [STAThread] to make the method single threaded but it seems to be getting ignored.
I'm at a loss as to how to instantiate a browser control in a web service. I need to do this so I can send HTML to a printer on the same box as the web service that runs.
thanks!
|
|
|
|
|
Well, AFAIK, IIS doesn't run in single-threaded apartment. You'll have to create another application that can run in single-threaded apartment and make a remoting call to it. For instance, try writing a console app or windows service and have your web method call that. I was wondering if you could create a new AppDomain with a different apartment threading model, but it doesn't look like that's possible.
www.logifusion.com
|
|
|
|
|
That sounds like a workable idea but I dont know how to make a call on an external app from a web service (or from any other windows code for that matter) I'm from linux/java/c and doing these things in windows, I just dont know how yet.
Anyone shed any light on how to make a call out to an external app from a web service?
Thanks!
|
|
|
|
|
|
C# novice - seeking feedback on the proper way to code a break report.
If you had two cvs files and needed to create a break report: (i.e. records in a but not in b, in b but not in a, in a and in b but mis-matched on data, how would you approach it?
I'm planning on loadeing the data into two DataTables, a and b, I've defined within the code, and looping as follows:
foreach (row in a)
find row.key in b
--if not found, copy source row into a-not-b table
--if found, compare
--- if not matching, copy rows and break info into data-break table
--- either way, if found, remove matched row from b table
end foreach
report a-not-b
report b (any remaining rows represent b-not-a)
and data-break
I'm concerned that I don't know the .Net language well enough, and I might be going about this the wrong way. Are there better choices in loading the data that provide 'set-operations' that I can use, to make this process cleaner?
Thanks!
Pauli
|
|
|
|
|
|
hello,
i am attempting to create a program using windows forms. there is a MDIParent form with several children. i have programmatically set the size of the child forms in the constructor, but for some reason they are popping up the wrong size. this is also happening with several controls that i've created. i have no idea why this keeps happening. can anyone help?
thanks!
rc
|
|
|
|
|
IIRC you need to set the FormStartupPosition property to Manual . You need to set both the Location and Size in parent coords.
|
|
|
|
|
Hello
I'm pretty new for the most part to programming in C# and I'm attempting to do something that I haven't been able to locate a solution for. Any help would be appreciated.
I have a text file with data in it that looks kind of like this:
BHG0002304050
BHG9459895944
BHG94859489568
I was able to write a snippet of code that would read that information into a string array so it looked like this:
Array[1] = BHG0002304050
Array[2] = BHG9459895944
Array[3] = BHG94859489568
However, I now want to separate each character within the array into it's own array... so it would look like this:
array1[1] = B
array1[2] = H
array1[3] = G
array1[4] = 0
etc.
I'm not sure I'm doing this the correct way so any help would be appreciated. If you have any suggestions on how to do this a different way then I'm explaining it I'm very open to ideas.
The reason for this is I will be using each of these characters in this datafile into a mathematical formula, each line represents a math formula... so I need to keep each line separate but I need to pull each character from each line if that makes sense.
thanks!
|
|
|
|
|
string[] t = reader.ReadToEnd().Split('\n');
char[][] all = new char[t.Length][];
for (int i = 0; i < t.Length; i++)
{
t[i] = t[i].Trim('\r');
all[i] = t[i].ToCharArray();
}
|
|
|
|
|
Thanks for the quick response.
This example really helped me get it figured it.
-- modified at 15:34 Friday 19th May, 2006
|
|
|
|
|
You can access the chars of each string directly:
Array[1].Chars[0] = B
Array[2].Chars[3] = 9
etc.
Scott
|
|
|
|
|
please help!
i am working in a c# GDI+ application but i got a problem in producing a pure flickering free screen, i am drawing on a panel and am using the following way to double the buffer but no use!
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
Graphics g = e.Graphics;<br />
<br />
<br />
Graphics g = this.panel1.CreateGraphics();<br />
offScreenBitmap = new Bitmap(this.panel1.Width,this.panel1.Height);<br />
Graphics g2 = Graphics.FromImage(offScreenBitmap);<br />
Brush b = new SolidBrush(this.panel1.BackColor);<br />
<br />
g2.FillRectangle(b, new Rectangle(this.panel1.Location,this.panel1.Size));<br />
g2.SmoothingMode=SmoothingMode.AntiAlias;<br />
flowChart1.Draw(g2);<br />
<br />
g.DrawImage(offScreenBitmap, new Point(0,0));<br />
g2.Dispose();<br />
b.Dispose();<br />
<br />
}
but i still have flickering screen, where is the problem?
and i am trying the the following code to double the buffer
SetStyle(ControlStyles.AllPaintingInWmPaint, true);<br />
SetStyle(ControlStyles.DoubleBuffer, true);<br />
SetStyle(ControlStyles.UserPaint, true);<br />
SetStyle(ControlStyles.ResizeRedraw, true);
but dose't work!
reply asap please!!
|
|
|
|
|
See-S wrote: Graphics g = this.panel1.CreateGraphics();
You should not have to Create the graphics. Rather handle the Paint event seperately.
|
|
|
|
|
You aren't using the Graphics object attached to the Panel's off-screen buffer because you're calling CreateGraphics() on the Panel. Use e.Graphics instead.
Josh
|
|
|
|
|
thanks leppie and Josh!
i see, but again it doesn't work.
but now i substituted a pictureBox for the panel and itworks well!
thanx
|
|
|
|
|
There is the thing: I need to create a Vitrual Drive wich is mapped into a file (an XML one).
This file needs to simulate a tree stucture from the disk.
Is there a .Net way to do this?
... Just asking
www.brusella.com.ar[^]
|
|
|
|