|
That didn't seem to make much difference. oh well.
|
|
|
|
|
Are you running the command on the machine you are testing it on? You could also run ngen on any non-system assembly that you use.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
Yes, I ran it on the machine its running on. It seemd to make no difference at all in startup time.
James T. Johnson wrote:
You could also run ngen on any non-system assembly that you use.
I dont quite understand this?
The program is a database app... when started nothing happens for a while then the UI starts to draw then nothing happens again for a while, then finally the rest of the UI draws and away we go. Maybe the connection to the database is whats slow? (although its just a local MDB database).
|
|
|
|
|
paulb wrote:
Maybe the connection to the database is whats slow? (although its just a local MDB database).
Beings that your db is local, I can only assume the time delay could be related to the processor speed(P133 and .NET application?).
Nick Parker
|
|
|
|
|
Is ur machine on a domain based network, if thats the case there is a bug in the framework (which can be worked around) which increases the app startup time. It has something to do with the 'aspnet' user account which needs to be configured on the deployed machines under the 'guest' users. I happen to see this on the .net mailing list.
If this isnt (the machine not on a domain) the case, I think you will have to accept the fate.
Cheers
Kannan
|
|
|
|
|
I tried running the ngen utility on couple of programs I have written, there doesnt seem to be any significant improvement in performance.
Is it something to do with any of the command line switches or to do with it will only work for certain type of apps.
Have you tried using ngen and seen any performance improvement.
Also, I believe that ngen simply reduces the process of the IL being compiled during the time of invokation(ie if u use ngen on a assembly the process of compilation to machine code after loading the assembly is skipped). Is this the right understanding.
Thanks
Kannan
|
|
|
|
|
Yes, thats the correct understanding...
Here's why
Currently there are two JITters with .NET, the runtime JIT and the install-time JIT. The runtime JIT is what you get by default; it works a method at a time. The install-time JIT takes an entire assembly and performs the MSIL -> x86 conversion on it.
The performance improvement you see depends on how your program is structured, if you do a lot of processing on startup (and probably a lot of method calls) then running the install-time JIT will help out because you won't incur the JIT for every method call.
If you don't do a lot of startup processing then there is a good chance you won't see any effect right away if at all.
But (!) there is no guarantee that the framework won't re-JIT your assembly even if you've run ngen on it. If it thinks there is a reason to believe the underlying IL has changed it will reJIT the assembly, but I cannot remember if it reJITs all of it or if it reverts back to runtime JITting.
James
Simplicity Rules!
|
|
|
|
|
Thanks James for the Info'.
I never knew anything on reJITing ... but I couldnt follow when you said the underlying IL has changed.. u mean how the m/c code is aligned or something of that sort ..Any idea on how do I do the install time JIT stuff, I remember long ago I read an article which said the JITing happens not once or all at a time but only when a particular portion of the code is used eg. a method call is done.
thanks
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
but I couldnt follow when you said the underlying IL has changed..
In a .NET application it is possible to change the image of the assembly at runtime. John Lam does this in his aspect weaver, and the JITter does this whenever it JITs a method [before a method is JITted the x86 has a jmp to a stub function that does the JIT, that jmp is then replaced once the method has been JITted].
Kannan Kalyanaraman wrote:
Any idea on how do I do the install time JIT stuff
ngen is the install-time JIT utility, so you'd just run that program during your setup.
Kannan Kalyanaraman wrote:
I remember long ago I read an article which said the JITing happens not once or all at a time but only when a particular portion of the code is used eg. a method call is done.
The runtime JIT works this way. When a method is JITted any method calls are looked up to see if the method has already been JITted, if it has it outputs an x86 jmp instruction to that method's x86 code; if it hasn't been JITted it instead outputs a jmp instruction to a stub function, which when executed will start the JIT process.
James
Simplicity Rules!
|
|
|
|
|
I'm currently trying to get a remote object, using Remoting... I can get the object, but I can't grab a event the object fires. This is all example code and I just can't seem to get it work. I get the object, but the remote object doesn't see the client sign up to watch for the event, so it never fires the event. Or if you have a better way for my Server and Client to communicate, don't hesitate to share.
Any help with would greatly appreciated. If you have more questions, please email me.
[Server]
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace Test.Remote
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Server
{
static void Main(string[] args)
{
TcpServerChannel channel = new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject), "Hi", WellKnownObjectMode.SingleCall);
Console.WriteLine("Hit to exit");
Console.ReadLine();
}
}
}
[Client]
using System;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace Test.Remote
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Client
{
[STAThread]
static void Main(string[] args)
{
//RemotingConfiguration.Configure("Client.exe.config");
ChannelServices.RegisterChannel(new TcpClientChannel());
RemoteObject obj = (RemoteObject)Activator.GetObject(typeof(RemoteObject), "tcp://localhost:8086/Hi");
EventSink sink = new EventSink();
// register client sink in server - subscribe to event
obj.Status += new StatusEvent(sink.StatusHandler);
obj.LongWorking(5000);
// unsubscribe to event
obj.Status -= new StatusEvent(sink.StatusHandler);
obj.LongWorking(5000);
Console.WriteLine("Hit to exit");
Console.ReadLine();
}
}
}
[RemoteObject]
using System;
namespace Test.Remote
{
[Serializable]
public class StatusEventArgs
{
public StatusEventArgs(string m)
{
message = m;
}
public string Message
{
get
{
return message;
}
set
{
message = value;
}
}
private string message;
}
public delegate void StatusEvent(object sender, StatusEventArgs e);
/// <summary>
/// Summary description for Class1.
/// </summary>
public class RemoteObject : MarshalByRefObject
{
public RemoteObject()
{
Console.WriteLine("RemoteObject constructor called");
}
public event StatusEvent Status;
public void LongWorking(int ms)
{
Console.WriteLine("RemoteObject: LongWorking() Started");
StatusEventArgs e = new StatusEventArgs(
"Message for Client: LongWorking() Started");
// fire event
if (Status != null)
{
Console.WriteLine("RemoteObject: Firing Starting Event");
Status(this, e);
}
System.Threading.Thread.Sleep(ms);
e.Message = "Message for Client: LongWorking() Ending";
// fire ending event
if (Status != null)
{
Console.WriteLine("RemoteObject: Firing Ending Event");
Status(this, e);
}
Console.WriteLine("RemoteObject: LongWorking() Ending");
}
}
}
[EventSink]
using System;
using System.Runtime.Remoting.Messaging;
namespace Test.Remote
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class EventSink : MarshalByRefObject
{
public EventSink()
{
Console.WriteLine("EventSink: Constructor called");
}
[OneWay]
public void StatusHandler(object sender, StatusEventArgs e)
{
Console.WriteLine("EventSink: Event occurred: " + e.Message);
}
}
}
-wzrd
wizardque@yahoo.com
|
|
|
|
|
I would like to write a Windows app that looks like (e.g.) Microsoft Outlook. I thought it would be easy - I hosted a WebBrowser COM control in my Windows form, and pointed it at a frameset containing the graphic buttons on the left. The buttons loaded different local html pages on the right. So far so good.
Now I want to host some Windows.Forms controls in one of my pages on the right. My idea is to derive my own controls from Windows.Forms controls, and have them interact directly with my app. I followed some tutorials on doing this, but they all assume the html page is on a Web Server. Mine is local ("file://" instead of "http://").
So I created an object like this...
< object id="testControl" classid="file:MyControls.dll#MyControls.TestControl" height="300" width="300" VIEWASTEXT> < /object>
But it doesn't work. Is it something I'm doing, or a bug, or isn't it supposed to be possible?
|
|
|
|
|
Hi all,
What is the best way to convert C style structures to C#.
I have converted the following C structure
typedef struct {
ISC_DATE timestamp_date;
ISC_TIME timestamp_time;
} ISC_TIMESTAMP;
to
public struct ISC_TIMESTAMP
{
long TIMESTAMP_DATE;
ulong TIMESTAMP_TIME;
};
Is this correct or should I be using another more C# style like..
[StructLayout(LayoutKind.Sequential)]
public class ISC_TIMESTAMP
{
// rest of code goes here
}
How about this more complicated C structure...
typedef struct blobcallback {
short (ISC_FAR *blob_get_segment)
(void ISC_FAR* hnd, unsigned char* buffer, ISC_USHORT buf_size, ISC_USHORT* result_len);
void ISC_FAR *blob_handle;
ISC_LONG blob_number_segments;
ISC_LONG blob_max_segment;
ISC_LONG blob_total_length;
void (ISC_FAR *blob_put_segment)
(void ISC_FAR* hnd, unsigned char* buffer, ISC_USHORT buf_size);
ISC_LONG (ISC_FAR *blob_lseek)
(void ISC_FAR* hnd, ISC_USHORT mode, ISC_LONG offset);
} ISC_FAR *BLOBCALLBACK;
What is the best way to handle this type of conversion.
Sincerely,
Dominique.
|
|
|
|
|
Dominique wrote:
public struct ISC_TIMESTAMP
{
long TIMESTAMP_DATE;
ulong TIMESTAMP_TIME;
};
Is this correct or should I be using another more C# style like..
[StructLayout(LayoutKind.Sequential)]
public class ISC_TIMESTAMP
{
}
You need to use a combination of the two, keep it a struct but apply the StructLayout attribute its your only guarantee that the data will stay in that order; otherwise the compiler could move fields around to better align the data.
Dominique wrote:
struct blobcallback {
short (ISC_FAR *blob_get_segment)
(void ISC_FAR* hnd, unsigned char* buffer, ISC_USHORT buf_size, ISC_USHORT* result_len);
void ISC_FAR *blob_handle;
ISC_LONG blob_number_segments;
ISC_LONG blob_max_segment;
ISC_LONG blob_total_length;
void (ISC_FAR *blob_put_segment)
(void ISC_FAR* hnd, unsigned char* buffer, ISC_USHORT buf_size);
ISC_LONG (ISC_FAR *blob_lseek)
(void ISC_FAR* hnd, ISC_USHORT mode, ISC_LONG offset);
}
Call backs are done with delegates, there is an article somewhere on CP that shows how to use a callback for the EnumWindows function, i think it was how to programmatcally control IE.
void is usually a object
When you have a character buffer pass in a StringBuilder object
A ** (pointer to a pointer) usually uses the 'out' keyword followed by its type, a pointer is usually a reference ('ref').
HTH,
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
Hello!
I'm a computer science student and want to start coding with Visual Studio .Net in C#. As I want to use my Apps commercially, the Student-licence doesn't seem to be usefull for me. On the other hand I doesn't have the money to buy the professional version of .NET. And I don't nedd any Server things or other languages than C#. So The Visual C# .NET Standard edition seems to be the right thing for me. So I looked at the comparison-table at http://msdn.microsoft.com/vcsharp/howtobuy/choosing.asp and there it says, that NOT supported are:
-Class Libraries
Create reusable class library components using the Class Library template
Does that mean, I cannot program class libraries?!? Or is only the template missing?
-Windows Control Libraries
Construct custom user interface controls for Windows Forms using the Windows Control Library template.
The same question: Does that mean, I cannot program custom control libraries, or is only the template missing?
If you have any serious warnings NOT to buy this edition, please let me know.
Mario
|
|
|
|
|
Mario, I bought the standard version as well and ran into the same issues you have. There are quiet a few templates that are missing. However, after doing some searches, MS has claimed that they inadvertently left of some of the templates in the standard edition and will be providing an update (Not sure which templates they are referring to). With that said some people have found ways to add various templates back in. Here is a link for the class library template. It works great.
http://groups.google.com/groups?hl=en&lr=lang_en&ie=ISO-8859-1&oe=ISO-8859-1&th=1610d3f841479209&rnum=1
In response to your questions, you can create libraries and controls, it's just a manual process. The templates make things much easier
|
|
|
|
|
Must i write the codes to parse a email message from a pop3 server myself ?
thanks
Thanks to those people with an "opensource" heart. they make me love what I am doing.
|
|
|
|
|
SoftArtisans has created a free POP3 control that you can use.
SoftArtisans POP3 Control - Source Code is included.
It doesn't look like it has been upgraded from Beta 2 yet, but the changes should be fairly minor.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
James T. Johnson wrote:
SoftArtisans has created a free POP3 control that you can use.
SoftArtisans POP3 Control - Source Code is included.
It doesn't look like it has been upgraded from Beta 2 yet, but the changes should be fairly minor
Thanks James
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Brian Delahunty wrote:
one of my boys on the inside instead of the outside
benjymous wrote:
All the male CP inhabitants cross their legs in unison
|
|
|
|
|
I wanna expand the ability of some class provided by framework like Bitmap, but I find it modified by sealed.
How can i do with it?
Another similar problem is when i try to inherit XmlElement, I find its construction is modified by internal. Then the compiler find it as an error. any solution to bypass?
|
|
|
|
|
I had the same problem with SqlDataReader. I just created a new class that wrapped each SqlDataReader method and property and then inherited from my class. It kind of sucks but I don't think there is any other way.
|
|
|
|
|
Well, the wrapper is boring but i fininally made it.
I think if Microsoft holds its position on sealing their class, then it will be a good idea to design a wizard to automatively build a wrapper. Hope C#'s reflection ability will make it possible.
Do you think so?
|
|
|
|
|
Yes it stinks. The reason for Bitmap being sealed is because it is a wrapper around GDI+ which is a native DLL. .NET doesn't support inheritence from a native image, yet anyway
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
I can't speak for them all...
but some are sealed for performance reasons.
and I quote from "Applied Microsoft .NET Framework Programming":
" the CLR knows the exact layout of the fields defined within the String type, and the CLR accesses these feilds directly." ... If String were not sealed, "you could add your own fields, which would break the assumptions the CLR makes, In addition, you could break some assumptions that the CLR has made about String objects being immutable."
|
|
|
|
|
Andy Smith wrote:
and I quote from "Applied Microsoft .NET Framework Programming":
" the CLR knows the exact layout
Here is Mircosoft "knowing" everything again...
Nick Parker
|
|
|
|
|
How can I draw a bitmap button with a transparent background.
Im using the code below to try and do this but its not working how it should.
Bitmap b = new Bitmap("D:\\-=[Pics]=-\\test.jpg");
b.MakeTransparent(b.GetPixel(0,0));
pe.Graphics.FillRectangle (Brushes.Transparent,ClientRectangle);
pe.Graphics.DrawImage(b,ClientRectangle);
Im trying to paint the button transparent then draw an image whose transparency key is the same as the color at 0,0 of the bitmap. It sort of works but when the image is drawn on the button the background looks more like swiss cheese than transparent.
Any help would be great.
Thanks Danny
|
|
|
|