If you create your own project installer (System.Configuration.Install.Installer), you can easily get the install path by just using reflection on the executing assembly. Here is some code I use to do this in my installer:
/// Since this assembly is being run from the install directory, it will return the full
/// path to this assembly. You can simple get the directory path using a FileInfo object
/// to know where it's been installed.
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
string baseAppDir = (new System.IO.FileInfo( asm.Location )).DirectoryName;
/// We're certain this exists because our setup program created it.
RegistryKey softwareKey = Microsoft.Win32.Registry.LocalMachine
.OpenSubKey( "Software", true )
.OpenSubKey( "Company Name", true )
.OpenSubKey( "Application Name", true );
softwareKey.SetValue( "InstallLocation", configFilepath );
Keep in mind that I added a registry value in setup project that creates the HKLM\Software\Company Name\Application Name\InstallLocation key with some default or empty value. The setup project actually creates the keys you specified in the registry editor part of the setup project before it calls your code in the Installer class.
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
IDataService obj = RemotingServices.Connect(typeof(IDataService),
ConfigurationManager.AppSettings[WebConfigContants.REMOTINGSERVERURL]) as IDataService;
The exception I get back on the web site client is to the effect
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.Remoting.RemotingException: The argument type 'MyDomain.MyDomainClass' cannot be converted into parameter type 'T'.
at System.Runtime.Remoting.Messaging.Message.SoapCoerceArg(Object value, Type pt, Hashtable keyToNamespaceTable)
at System.Runtime.Remoting.Messaging.MethodCall.SetObjectFromSoapData(SerializationInfo info)
at System.Runtime.Remoting.Messaging.MethodCall.SetObjectData(SerializationInfo info, StreamingContext context)
at System.Runtime.Remoting.Messaging.MethodCall.RootSetObjectData(SerializationInfo info, StreamingContext ctx)
at System.Runtime.Remoting.Messaging.SerializationMonkey..ctor(SerializationInfo info, StreamingContext ctx)
--- End of inner exception stack trace ---
Server stack trace:
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage(Stream inputStream, Header h, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
I have a requirement to draw a rectangle and a line on a the
container control and sometimes as i move the mouse the drawing must
occur on top of user controls and other controls, which are placed in
the container control...
I'm using System.Drawing namespace (C#) to perform the drawing.
But as i move the mouse and draw the rectangles, the drawing takes
place behind the user controls....I have a requirement to draw the
shapes on top of the controls...
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
I have developed a windows form application.Now,i am using task manager to monitor its perfomance,i got that the cpu usage is lower(but sometime will raise to 9) ,but when i look at the memory usage(In Processes),i was used about 40000k memory to 60000k memory, sometime even higher than these values.I will very appreciate if anyone can tell me my application is consider high perfomance or low perfomance? (How to evalute?)
If my post is place wrongly,please guide me where should i get my answer.
to me performance is measured in functional results per unit of time, so it does not involve CPU load or memory footprint. Functional results could be
transactions/second in a database, pages/minute printed in a report tool, etc.
I can not tell you whether your app is hi or lo performance. Do you consider a
10 page/minute printer fast or slow ??
You can compare with two kinds of things:
- the performance of another program with similar functionality;
- your own expectations.
In either case, you (or your customers) will be the judge.
Having the same performance at a lower cost (less CPU load, smaller memory footprint)
can be an added bonus. It could become relevant if your app is being ran by
several concurrent users on the same machine (especially if a server app).
Thanks for reply.Actually my application is using for monitory[include displaying data in chart format(in real time,display 30 charts at the same time with using thread ),generate log file and save into database & textfile, and report view function] certain information which get from third party device through seriall port. Each 3 sec will get request a data from third party device.
May be i should change my question,it should be "Isn't a good quality application which develop by using c#?"
Anyway,you have gave me a good answer on it.Thanks
I am not sure I understand the question. If you mean to ask "Can we develop quality
software in C# ?" the answer is yes (you can in any language, some make it easier
to achieve quality and/or productivity, and C# certainly is amongst them).
If you mean to ask "Can we develop the highest performance app with C# ?" then
I would say you can achieve good performance with C#, but you also can waste a lot
of performance using it. And you might get somewhat better (or even much better) perfo
when staying closer to the hardware (anything from C++ downto assembly code,
e.g. when you want to exploit the vector processing capabilities known as MMX and SSE
Is it ? I'll ask a lot of questions now, you dont have to provide the answers, I just
want to make you think a bit more about it.
By how much, i.e. what kind of speed up would you want ?
Do you think that is achievable ?
If so, why dont you have it right now, i.e. where are you loosing it ?
Is there a particular part of your app responsible for its (lack of) performance ?
I recall your CPU load was low, so this seems to indicate you are mainly waiting
on something. Any idea what ? (the database ? the network ? running out of sockets ?
having a resource leak ? swapping virtual memory all the time ?)
Is the UI responsive all the time (if not you definitely did something wrong) ?