|
Yah missed the restriction of c#, I was thinking I have images, files, MDFs all somewhat larger than 2gb
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Really? My vhd is 16GB in one file...
V.
|
|
|
|
|
Files are fine - but you can't load the whole thing into any single object as that would exceed the .NET 2GB limit.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
|
|
In addition to the answers about single object, there is also a difference between 32 and 64 bit applications in how much memory they can address. I am not sure how this works out for .NET, but for a general Windows application a 32 bit program will have, at best, around 3 GB's of memory in its address space. This is then filled up even more with loaded DLL's, file handled, objects, etc, so it could be considerable less than that.
For 64 bit, you have relatively unlimited addressable memory available. However, the actual amount you can use is still limited by physical memory, page file and other factors. Also, the 2 GB per-object limit probably still applies. Furthermore, it is always easier to allocate a lot of small chunks than to allocate one big chunk, so creating 4 512 MB objects has more chance of succeeding than one 2 GB object.
|
|
|
|
|
MicroVirus wrote: Also, the 2 GB per-object limit probably still applies.
Yes it does.
I also find the absense of 64-bit indexers for arrays a bit puzzling. I mean really, it's a freakin' pointer! You mean to tell me you can't have a 64-bit pointer on a 64-bit CPU? I don't think so...
|
|
|
|
|
In my current C# project, I am using an instance of the SerialPort class. I wanted to examine each character as it came in, so I registered a handler for the DataReceived event and set the ReceivedBytesThreshold property to 1. With these settings, I expected that the event handler would be called for each character received but I find that it only gets called once for every 5-8 characters. This is good for communication efficiency, but for what I want to do, I have to loop through the received characters in my event handler. Does anybody know if this is the expected behavior of this class?
|
|
|
|
|
There is an interesting discussion of this question here[^]
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks for the pointer.
--
Regards, Ken
I AM
|
|
|
|
|
I am not surprised, asynchronous receive is a complex process, there are several actors, and some buffers with their sizes and thresholds, some of which one cannot control at all.
You should not be lazy and refuse to loop over the bytes you get in one go, that is pretty easy to accomplish.
It gets really nasty when you have to implement a message-oriented protocol, where the sender sends two or more messages back-to-back, and your receiver unfortunately receives three or more DataReceived events, each covering an arbitrary part of the messages sent (say first half of first msg, then second half+first half of second msg, finally second half of second message).
The only serial receive that goes smoothly is the one that has a fixed message separator (say a NEWLINE) which is guaranteed to appear in between messages and never inside a message (in that case set the NewLine property and use ReadLine). If that is not the case, get ready to collect what you get, whatever amount comes in, then re-packetize it according to your needs.
And then, you should carefully consider whether you need some recovery mechanism, something that helps you out in case some character gets damaged or lost...
|
|
|
|
|
I am quite familiar with the intricacies of communication code. I have written a number of serial drivers for embedded systems over the past 20 years or so. My use of C# has been limited to writing "quick & dirty" utilities for testing my embedded systems. In this case, my code was working fine - I was just seeking a better understanding of the SerialPort class which did not behave as I expected and the Microsoft documentation for it is shallow at best.
--
Regards, Ken
I AM
|
|
|
|
|
Greetings!
I would like to use Visual Studio's Database Designer to set up the data sets my application is going to need. But I am going to need the name of the database (or its DSN) to be configurable at run time. When I set up the objects, the connection string is stored in my applicaton's config file. But my application will have a separate settings file (an old-style .ini file). I would like to be able to change the connection string to whatever is contained in that file. How can I adjust the connection string before opening the database?
Thank you very much!
RobR
|
|
|
|
|
Interrobang wrote: I would like to use Visual Studio's Database Designer to set up the data sets my application
This is a good idea when you first start out and are still learning but it is not a viable long term solution. Look into using a data access layer DAL, there are many examples here on CP.
Using a DAL will give you a much deeper understanding of where and how your data is manipulated. It will also make this question irrelevant as you will have all the control over your data access you need.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
None of what you mentioned is professional grade, so you won't get much professional advice on how to do it.
|
|
|
|
|
Hi guys,
how to show or hide caption video using AxWindowsMediaPlayer component?
I try with closeCaption but not work.
Thanks to all.
|
|
|
|
|
|
what is the concept of it ???
how can i get one ???
I heard about "Unity" & other things but i am new in this field
I really need help ,,, thanks
|
|
|
|
|
A game engine is normally a black box piece of software that handles the internals of game creation, and provides an API for you to work with to create your own games. In a 3D game engine, for instance, the engine will take care of things such as loading textures and models, provide physics capabilities, lighting, etc.
As for where you can get one - there are several available, and there prices range from free up to several hundred thousand pounds depending on their target audience.
|
|
|
|
|
Pete O'Hanlon wrote: prices range from free up to several hundred thousand pounds
...and from what I can tell, you get what you pay for!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
OriginalGriff wrote: ...and from what I can tell, you get what you pay for!
Yes, and no
Most of the expensive engines also have free versions for home or hobby use, and some only require licensing if you release a product commercially.
There are also some excellent free engines (oh, and some horrible commercial ones As an ex-game developer I could tell you some horror stories about well-known engines...).
I'm not going to try to recommend a good engine, but DevMaster has a huge list of what's out there in all categories.
[ I've also just noticed there's a game development forum here now as well! ]
Days spent at sea are not deducted from one's alloted span - Phoenician proverb
|
|
|
|
|
Hi,
I need to get all installed languages on the computer. "Control Panel / Regional and Language / Keyboards and Languages / Display language". How can I get the selected language in .NET?
Our application has language settings for a lot of different languages. If our application don't has support for the selected language in "Display language" then we have to see if we has support for a fallback language.
I tried to use "GetThreadPreferredUILanguages" call and it work fine when I use C++, but I can't get is working on .NET. Is there an .NET call I can use instead to get selected languages and also the fallback languages?
C++ code
wchar_t buf[2323];
wchar_t *pBuf;
ULONG numLangs;
ULONG size= 2323;
GetThreadPreferredUILanguages(MUI_MERGE_USER_FALLBACK, &numLangs, buf, &
C# code
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
static extern System.Boolean GetThreadPreferredUILanguages(
System.UInt32 dwFlags,
ref System.UInt32 pulNumLanguages,
out System.IntPtr pwszLanguagesBuffer,
ref System.UInt32 pcchLanguagesBuffer
);
uint MUI_MERGE_USER_FALLBACK = 0x20;
uint numLang = 0;
IntPtr pwszLangBuf = new IntPtr();
uint langBuf = 2323;
bool b = GetThreadPreferredUILanguages(MUI_MERGE_USER_FALLBACK, ref numLang, out pwszLangBuf, ref langBuf);
string tmp = Marshal.PtrToStringAuto(pwszLangBuf
tmp string variable contains only a lot of chinese characters after Marshal.PtrToStringAuto(pwszLangBuf);.
pulNumLanguages and pcchLanguagesBuffer returns the same in both C++ and C#.
See more information about GetThreadPreferredUILanguages on
http://msdn.microsoft.com/en-us/library/dd318128(v=vs.85).aspx[^]
What is wrong?
Regards
Olof
|
|
|
|
|
Hi,
1. I'm not familiar with GetThreadPreferredUILanguages however I do know a thing or two about P/Invoke, and wrote a little article[^] on the subject. What you need here goes beyond the scope of my article though.
2. Your C# code is not doing what your C code does; in particular you should preallocate the result buffer, as you did with wchar_t buf[2323]; . The native function you're calling expects a third parameter pwszLanguagesBuffer that is either a NULL, or a valid pointer to a buffer you provide for it to fill.
3. This seems like a reasonable approach: create a byte buffer, have it pinned (with GCHandle), call the native function, then use some kind of Marshal.PtrToString() for each string you need to extract from the buffer. Free the handle once all strings got extracted.
4. I would recommend you call GetThreadPreferredUILanguages twice, once without an output buffer (IntPtr.Zero), just to get the required buffer length; then the regular call with a sufficient buffer size.
|
|
|
|
|
Have a look at the documentation for CultureInfo[^] and related classes.
|
|
|
|
|
Hi
First of all please forgive me, I seem to be having a bit of a mental block! I've been trying to improve my exception handling and error logging.
I have a function ProcessPerson(). Within that function I call a ValidateUser() function. And within that function I call the GetAdmin() function. Would the following be acceptable or if not, how should it be done?
I have omitted unimportant code, so:
public void ProcessPerson(Request arg)
{
try
{
if(Class2.ValidateUser(arg.Username, arg.Role)
{
}
else
{
}
}
catch(ArgumentNullException ex)
{
}
catch(Exception ex)
{
}
}
public static bool ValidateUser(string Username, string Role)
{
try
{
using(MyClass myClass = new MyClass())
{
if(myClass.GetAdmin(Username, Role)
return true;
else
return false;
}
}
catch
{
throw;
}
}
public bool GetAdmin(string Username, string Role)
{
if(String.IsNullOrWhitespace(Username) || String.IsNullOrWhitespace(Role))
{
throw new ArgumentNullException("e.g. Username or Role cannot be null");
}
try
{
using(MyClassAdapter myClassAdapter = new MyClassAdapter ())
{
myClassAdapter.GetAdmin(Username, Role);
}
}
catch(ArgumentNullException ex)
{
throw;
}
catch(Exception ex)
{
throw;
}
}
Appreciate any help or advice.
Thanks
modified on Wednesday, September 14, 2011 5:01 AM
|
|
|
|
|