|
Yes, a windows service will, by default, run using the latest available Fx version (in this case Fx 3.5) [A minor correction, the CLR version from Fx 2.0 on is still CLR version 2.0.]
From inside the process you can access the Environment.Version[^], which will return the version number of the CLR you are running under (not the Framework).
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Scott Dorman wrote: Yes, a windows service will, by default, run using the latest available Fx version
This is a new info for me. Even the service is targeted to framework 2.0, it takes the latest version ? Is there any documents to prove this ?
|
|
|
|
|
I am also asking this.
regards,
George
|
|
|
|
|
I haven't been able to find the documentation I saw this in, but it has to do with the way certain unmanaged applications (like IIS, SQL, DLLHost, etc.) actually host an instance of the .NET runtime. I'm still looking, so if I find the information I'll update the post.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Thanks Scott,
1. If in my process, I have not added any code to retrieve Environment.Version, how could I retrieve the CLR version it is using?
2. "A minor correction, the CLR version from Fx 2.0 on is still CLR version 2.0." -- I am confused. Sorry English is not my native language, do you mean .Net Framework 2.0 and CLR 2.0 are the same thing?
regards,
George
|
|
|
|
|
1 - You have to add and re-deploy your application.
George_George wrote: .Net Framework 2.0 and CLR 2.0 are the same thing?
They are not the same. One is a set of classes and other one is "Common language runtime". He meant .NET Framework 3.5 uses CLR version 2.0.
|
|
|
|
|
Thanks N a v a n e e t h,
1.
So, no way to know which CLR version is used from outsire?
2.
Have you found any documents saying Windows Service will always use latest CLR version other than the CLR version used to build it?
3.
N a v a n e e t h wrote: .NET Framework 3.5 uses CLR version 2.0
-- confused about this, you mean for the common parts between 2.0 and 3.5, like System.XXX and Net.XXX classes, they share the same binary code?
regards,
George
|
|
|
|
|
George_George wrote: Have you found any documents saying Windows Service will always use latest CLR version other than the CLR version used to build it?
I haven't been able to find the documentation I saw this in, but it has to do with the way certain unmanaged applications (like IIS, SQL, DLLHost, etc.) actually host an instance of the .NET runtime. I'm still looking, so if I find the information I'll update the post.
George_George wrote: So, no way to know which CLR version is used from outsire?
Not really, no. You could use a tool like ILDasm to inspect the PE header and manifest metadata, which will tell you what version of the CLR the binary was compiled against, but that isn't really going to tell you what version you may be running on. Are you asking because you are running in to a problem or is this just a "want to know" type of question? If you're running in to a problem, posting what that problem is may help get you the right information to resolve it.
George_George wrote: confused about this, you mean for the common parts between 2.0 and 3.5, like System.XXX and Net.XXX classes, they share the same binary code?
The thing to keep in mind here is that NetFx v3.0 and NetFx v3.5 are really a set of framework libraries (WPF, WCF, WF, Linq, etc.) that extend the runtime engine (the CLR) which is CLR v2.0. (This simplifies things a bit, since there are actually service packs that are distributed as part of NetFx 3.0 and 3.5 that are mandatory and irreversible once installed.)
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Thanks Scott,
Scott Dorman wrote: The thing to keep in mind here is that NetFx v3.0 and NetFx v3.5 are really a set of framework libraries (WPF, WCF, WF, Linq, etc.) that extend the runtime engine (the CLR) which is CLR v2.0. (This simplifies things a bit, since there are actually service packs that are distributed as part of NetFx 3.0 and 3.5 that are mandatory and irreversible once installed.)
So, for the common parts of library, like System, string, sockets and http related classes, they are common in 2.0/3.0/3.5 correct?
regards,
George
|
|
|
|
|
George,
There has always been some level of confusion regarding the differences between Framework (Fx) versions, CLR versions, and language versions. Here is a brief explanation up through VS2008 (.NET Fx 3.5): http://geekswithblogs.net/sdorman/archive/2007/06/12/Visual-Studio-2008.aspx[^]
As for retrieving the CLR version your process is using from inside your process the only real option is to add a call to Environment.Version.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Thanks Scott,
1.
From document you referred, I learned .Net Framework is the library, and CLR is used only for the runtime engine, manages the libraries, correct understanding?
2.
Do you have any document mentions for Windows Services, the lastest version .Net Framework other than the version used to make the build is used please?
regards,
George
|
|
|
|
|
George_George wrote: manages the libraries
.NET framework is a collection of classes, ofcourse a library. Common language runtime is the runtime where these libraries are executed.
|
|
|
|
|
Thanks N a v a n e e t h!
A further question -- "Do you have any document mentions for Windows Services, the lastest version .Net Framework other than the version used to make the build is used please?"
regards,
George
|
|
|
|
|
My problem is:
I have 3 main classes A, B and C (B and C are derivated from A)
I have a generic class F
And I have derivated F to work with B and C:
class FB : F<B>
class FC : F<C>
Now, in my main application I have a method that should work with FB and FC (also with any F<> that uses a A derivated type as parameter)
I tried to do this, but it doesn't compile:
void WorkWithData(F<A> data) {}
FB testB = new FB();
FC testC = new FC();
WorkWithData(FB);
WorkWithData(FC);
Is there anyway to fix it?
Thanks,
Dirso
|
|
|
|
|
With the current state of C# (and VB), that sort of thing is not possible. Apparently the CLR supports this sort of assignment (known as covariance and contravariance), but the C# and VB language teams decided not to implement it yet.
A decent series of blog posts that talk about the topic can be found here [^]
|
|
|
|
|
A suggested, have a google for covariance and contravariance. This is supported in some cases, if the type parameter is used in a read-only manner. IEnumerable<t> can be used covariantly, IList<t> can't.
You can make it work by declaring your method as:
void WorkWithData<t>(F<t> data) where T : A { ... }
The compiler may infer the appropriate specialization of WorkWithData for you. If not you'll have to call it like WorkWithData(testB);
|
|
|
|
|
Hi,
What is the fastest way to convert string array to double array? Currently, I am doing this:
double[] arrDouble = new double[arrString.Length];
for(int i=0; i<arrString.Length; i++)
{
arrDouble[i] = double.Parse(arrString[i]);
}
Unfortunately, this is quite slow for big array (about 3 millions). I am looking for a way to improve it. There is a link talking about converting object to double. http://blogs.msdn.com/bclteam/archive/2005/02/11/371436.aspx[^].
You will see that double.Parse is really slow because the object need to be converted to string before pass it to double.Parse. However, it is not the case here. My array is already a string array. I did test using Convert.ToDouble and it doesn't improve the speed.
Any idea?
Thanks for any help.
Cheers
|
|
|
|
|
This will always be a O(n) operation, you can't get it any faster than this. Are you sure you need 3 million items at the same time?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yeah, unfortunately
Thanks though for your help. At least I know there is nothing I can do about it.
Cheers
|
|
|
|
|
Just for curiosity. How long does it take to convert those 3 million items?
|
|
|
|
|
12 years later and we still haven't heard back. I can see why they wanted to speed this up.
|
|
|
|
|
I'm trying to do an drag and drop example but it failed.
my code is:
public partial class Form1 : Form
{
private String f;
public Form1()
{
InitializeComponent();
f = "D:\\Special";
String[] files = Directory.GetFiles( f );
foreach ( String fi in files )
{
listView1.Items.Add( fi );
}
}
private void listView1_ItemDrag( object sender, ItemDragEventArgs e )
{
DoDragDrop( new DataObject( DataFormats.FileDrop, ( ( ListViewItem ) e.Item ).Text ), DragDropEffects.Copy );
}
}
Please help me, it's very urgent.
|
|
|
|
|
Check out this article[^].
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Thank you for it, but I've already read it, and I did the same but it didn't work with me, that's why I'm so confused.
|
|
|
|
|
HI..
Im trying to move mails that have come into my inbox, that have a specific subject into a subfolder in my inbox. Im trying to do this using a c# application. Ive been working on this the whole day, cant seem to get it.
Also whenever i use the Folder.Folders methods i get a 'Microsoft.Office.Interop.Outlook.MAPIFolder.Folders' is a property but is used like a method error. this is how i use it:
Subfolder = namespace_.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox).Folders("Requests");
Thanks
|
|
|
|
|