|
if(IntPtr.Size == 8) {
//64-bit
} else if(IntPtr.Size == 4) {
//32-bit
}
This is based off the OS installed, not the CPU which is what I think you are looking for.
|
|
|
|
|
Environment.OSVersion is good enough for me.
your "ByVal" is obviously wrong, where is the output going to go?
|
|
|
|
|
Right now I'm just debugging the code and just looking "quick watch" on the structure.
As a first time .Net/VB coder it should be ByRef.
Now it works. I'll do more testing on other OSs
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
I'm using
DateTime.Now.ToString("M/d/yyyy") to try and format today's date.
I've noticed that when I change my regional settings through control panel, it changes the result I get from this method.
When I set my default date format to dd-MMM-yy in Control Panel, it changes the output of my ToString method from containing slashes (as I've specified in my format string) to dashes, which I can only assume are coming from my regional settings.
I thought the point of specifying my own format string was so that I could, oh I dunno, specify my own format?!
Are my control panel settings really affecting this method call? Why in the heck?
I realize I can just code my own cheesey routine to format dates and avoid the issue, but I'd like to understand what's going on here.
|
|
|
|
|
Hi,
a typical mistake. This page of MSDN documentation[^] tells you what the parts of the format string represent; M is an indicator for the month number, and / for the date separator. As a result regional settings are still infiltrating your app!
You could create your own DateTimeFormatInfo object and set all of its details any way you like, then pass that to DateTime.ToString() instead of a string.
[ADDED]
Or you could single quotes to escape the special characters you want to be taken literally, so use '/' to get a real slash, no matter what.
[/ADDED]
modified on Friday, December 25, 2009 3:46 PM
|
|
|
|
|
|
You're welcome.
|
|
|
|
|
I have a problem which is also related to AppDomain's and Windows messages.
A web page to be hosted in Internet Explorer that would contain a .Net WinForms UserControl derived control - HelloWorldCtl. This control is inside a C# written assembly - HelloWorldControl.dll. The control uses code from another assembly that is written in C++/CLR - HelloWorldLibCPP.dll.
HelloWorldCtl loads HelloWorldLibCPP.dll and calls code that would create a Win32 native window and places that window in HelloWorldCtl's area.
Navigate to the web page, HelloWorldCtl loads, I can see it as well as the native window in the center of HelloWorldCtl's area.
Both the C# control and the native window have some message handlers and the messages are all working fine and reaching both the C# control's window and the native window; mouse clicks, re-paints and so on... However, some of the message handlers of the native window need to call methods on the C# control which is the parent of the native window. This is done using an interface that the C# control implements and which the native window holds a reference to by storing it in a GCHandle (from System::Runtime::InteropServices.) I used the gcroot<> template for the GCHandle.
The failure is happening at this point when code in the native window is trying to use the GCHandle to call any method on the C# control. (The c++ code is compiled as managed code with /clr.)
The exception that is thrown is :
"Cannot pass a GCHandle across AppDomains"
I put some debugging code to display the Id and FriendName of the CurrentDomain in both the C# and the native window and I found out that these AppDomains are not the same.
During the creation of the native window, the CurrentDomain is the same as that of the C# control, but when the native window receives messages and those messages are handled, the CurrentDomain is different from the C# control's.
Can this situation be changed? Is it possible to have both the native window messages hanlder run in the same AppDomain as that of the C# control?
Any other suggestions perhaps?
Thanks,
Roger
|
|
|
|
|
Hi,
I am looking for a TAG control for my c# application. It is difficult to look for a TAG control on internet, since almost every webpage has the word "TAG" for another reason.
Does anyone know a preferable free TAG control that I can use?
Please look at the following links for examples of what a control should do:
* Drop down after typing a letter (http://ximp.nl/TAG/ExampleTagControl2.png[^]);
* Adding multiple tags by using a seperator (http://ximp.nl/TAG/ExampleTagControl1.png[^]);
If you know a control, please let me know. Any help is appreciated.
Gaston
modified on Tuesday, December 29, 2009 1:43 PM
|
|
|
|
|
I'm looking for the same thing. If we develop ourselves, I'll try to remember to point you to the code. Let me know if you've already gone ahead and done it.
|
|
|
|
|
Hello,
Unfortunately, I haven't done anything yet on this. Frankly I am not a very good programmer, so I hoped someone could help me out. I would really appreciate if I can lift on your skills. I can test and help with describing functionality.
If I can be of any help, please let me know.
Kind regards,
Gaston
|
|
|
|
|
hello.
in a C# WinForm project, i have put a webbrowser on a form,
in javascript, i have called the public methods of the parent form using window.external.
but it fail when the returned value of the method is a struct.
ladys and gentmans.
please teach me how to do it?
|
|
|
|
|
Is the description imprecise? thanks.
|
|
|
|
|
Hey,
I'm a little confused with the definition of a shallow copy. From the definitions I can find online, I get that reference types get copied, but not the value they refer to. In other words, they should point to the same value. However, when I test this, I can assign a new value to a reference type in either the original or the copy, and the value in it's counterpart won't change.
This is the code I used to test this:
Sub Main()
Dim list1 As New List(Of Spam)
list1.Add(New Spam(1))
list1.Add(New Spam(2))
list1.Add(New Spam(3))
Dim list2 As List(Of Spam)
list2 = list1.GetRange(0, list1.Count) ' this should make a shallow copy
list2.Item(1) = New Spam(5)
For Each s As Spam In list1
Console.Write(s.ToString & " ")
Next
Console.ReadKey()
End Sub
Private Class Spam
Public Sub New(ByVal v As Integer)
value = v
End Sub
Dim value As Integer
Public Overrides Function ToString() As String
Return value.ToString
End Function
End Class
The output of this code is "1 2 3", and not "1 5 3", which I'd expect from the definition of a shallow copy.
Please un-confuse me here
Cheers!
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
Dag Jeroen,
While you write
jeroen de dauw wrote: I can assign a new value to a reference type
that does not really make sense (a type is a type, a type does not have a value at all); and it is not what list2.Item(1) = New Spam(5) does. Yes list2 is a reference type (it is an object, not a value type), as lists and arrays are collections holding things of a single type (either value types of reference types themselves). In this case, the list holds reference types, i.e. references to Spam instances.
What your statement does is it overwrites an existing reference by a reference to a new object. So none of the existing Spam objects is being modified.
As your use of the terminology isn't correct, this suggests you got a few things confused.
A shallow copy copies everything: the data in value types and the data in a reference type. The trick is a reference type only holds a reference (think of it as a pointer), and that is what gets copied. The thing (object) it points to is not being copied or cloned, so the old and new pointers now point to one and the same thing.
To prove, or rather disprove, your statement about shallow copies, you should add a Value property to the Spam class, then execute list2.Item(1).Value = 17 and watch how both lists reflect the change, as you now would have changed an existing object, where both lists are referring to.
|
|
|
|
|
Well, now you said it, it seems so obvious
Thanks a lot for making me understand my error
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
First timer with VB and .Net
In the following code I get the displayed error when I execute the objOS.Get. I'm executing on an XP Pro SP3 and have all updates installed. I would assume
I'm missing something but WHAT? Any help is appreciated.
Dim objMgmt As ManagementObject
Dim objOS As New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
For Each objMgmt In objOS.Get
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Management.dll
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Management.dll
Additional information: The dependency service does not exist or has been marked for deletion. (Exception from HRESULT: 0x80070433)
TIA
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
I want to work with Memory Mapped Files. That's why I just installed the .Net framework 4.0 beta 2.
But now I can't find the System.IO.MemoryMappedFiles dll.
|
|
|
|
|
That's because there is no such .DLL.
If you read the documentation on the System.IO.MemoryMappedFiles namespace, you'll see that there is no need to import a .DLL because that namespace is exposed by the System.Core assembly, which every .NET app already uses.
|
|
|
|
|
Hi all,
Dose any one know about documentation oF MSPastry Library under MSDN that could be utilized in C# code?
thnaks to you all in advances
|
|
|
|
|
|
After working in Visual Studio 2008 with SP1 on my application, everything works sweet with visifire charts.
I then create an install for my application and deploy it to a seperate machine. Charts do not work, and we get system.exception with Eventype:clr20r3
Can visifire be run without VS 2008? I don't expect to install VS 2008 SP1 on every install instance of my app with visifire.
I'm using WPF, and am creating the chart dynamically through code. I'm using the latest stable/non-beta version of visifire, v2.1
|
|
|
|
|
You've been told about this, now please stop.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Dude. HYou've already been told that you should be waiting on an answer from VISIFIRE.
The chances of someone here using that package are very very low. If you have specific questions about a vendor's product, the best place to ask is the vendor or a vendors support forms.
You've got about the same chance of getting an answer on that package here as you do just going outside and asking the first person who walks by.
|
|
|
|
|
Have you tried the VISIFIRE forums. I just did a quick search on there and found a post immediately saying .Net 3.5 SP1 is required on the deployment machine.
|
|
|
|