|
You can read data from a DataSet simply by using the following code:
byte[] _Image = (byte[])myDataSet.Tables[0].Rows[0]["Image"];
MemoryStream ms=new MemoryStream(_Image);
Image image=Image.FromStream(ms);
Now you have your image reconstructed if you have stored it as binary data.
Akif
|
|
|
|
|
i've do it but i get error, maybe becouse i have set the image within Microsoft Access instead in my c#application.
Could be it the cause?
Just another question:
if i set another kind of file as a word file or a .xls how can know what kind the file is it?
|
|
|
|
|
I didnt get your point. Will you specify it in more details whats the problem
Akif
|
|
|
|
|
how can i use datasource as dataset in owc chart. I am using c# windows application. I want to use DataSet of VS.Net for the chart.
|
|
|
|
|
I wrote a little HTTP editor to modify the values of form variables in an HTTP request, without the having to hurt my eyes editing the raw text. My immediate vision was for a two column grid, for all the name=value pairs. I'm a little miffed that one has to get as extravagent as a DataGrid (WinForms) to achieve this.
Another of my ideas was to use a PropertyGrid, but that requires an object with one property corresponding to each form variable, with the complexity of having to generate that object on the fly.
Any ideas/suggestions on avoiding a DataGrid for such a simple application?
The DJ's took pills to stay awake and play for seven days. - Jim Morrison, Black Polished Chrome.
|
|
|
|
|
check this
http://www.dotnetjunkies.com/Article/65DC168F-B2AD-408B-8AA0-AD90DD739317.dcik
|
|
|
|
|
Thanks, that looks like a good read, but it's not what I'm looking for. I actually went through that exercise last year and solved it with a crude loop. This is a WinForms grid, not ASP, and they're quite different animals.
I needed to edit a collection of objects not related to the database, so through my trials I learnt that the collection needed to implement IList at minimum. My collection derived from DictionaryBase, and .NET Data Binding doesn't like that, so I first tried to implement IList but it got messy.
I then derived from CollectionBase, destroying my nice Dictionary based accessors etc. that operated like a Hashtable's accessors, replacing them with Add, Remove, and Item members that only return a Dictionary entry structure, leaving the onus on the client of the collection to extract name or value.
Now I still need to implement IBindingList and IEditableObject before the grid will behave as I want, and I keep thinking what a mission this is for what was supposed to be a one-hour project HTTP editor.
The DJ's took pills to stay awake and play for seven days. - Jim Morrison, Black Polished Chrome.
|
|
|
|
|
Hi
try this: (you find a complete collectionbase class that implement IBindingList, .....)
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=0B47DA60-DF5F-4A28-ABF7-6F8EB977FCFD
|
|
|
|
|
Is it at all possible to kill the error 'Not all code paths return a value'?
I have several classes that need to throw exceptions when some methods are called or the user tries to set some properties. ('You cannot bla bla bla on a NullObject') We're talking *lots* of different places that will throw this particular exception.
Since I am a structured kind of person, I'd like to standardize the message and information that is logged. Therefore I thought it would be smart to defer the actual throwing and logging to a common method that can be called from all the places.
However, when I do, the C# compiler complains that not all code paths return a value.
The code does exactly the same thing as before (throws an exception) except it's maintainable now, so how do I make the compiler stop bugging me about this ""error""?
I'm using VS 2005
Thanks on beforehand
/Joachim
P.s. I tried using #pragma, but it seems the compiler thinks this is a real error, and says '161' is an invalid warning number... Or did I do it wrong? Ds.
--
Ubi Signo?
|
|
|
|
|
I don't think you'll be able to suppress this error.
The only workaround I can think of is to let the method you use to throw the exception return a value, but this seems quite awkward, too.
I guess it would be better to log in the constructor of your exception or add an event handler for unhandled exceptions and perform your logging there.
Regards,
mav
|
|
|
|
|
mav.northwind wrote: I guess it would be better to log in the constructor of your exception or add an event handler for unhandled exceptions and perform your logging there.
Regards,
mav
Ah. Good idea. Didn't think of that. Will put the logic in the constructor for now.
Thanks for your suggestions.
Regards
/Joachim
--
Ubi Signo?
|
|
|
|
|
joachimF wrote: Is it at all possible to kill the error 'Not all code paths return a value'?
No.
joachimF wrote: I have several classes that need to throw exceptions when some methods are called or the user tries to set some properties
The compiler is intelligent enough to realise this. There must be some other particular path through the method that is not returning a value or throwing an exception.
joachimF wrote: I tried using #pragma, but it seems the compiler thinks this is a real error, and says '161' is an invalid warning number
That is correct. This is a real error. The code cannot compile while it exists.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Colin Angus Mackay wrote:
> The compiler is intelligent enough to realise this. There must be some other particular path through
> the method that is not returning a value or throwing an exception.
Are you sure? Perhaps there is an error in my code then.. Here it is;
public interface SomeInterface
{
void ChangeState();
int SomeFunction(int arg);
int SomeMethodWithSideEffect();
int SomeProperty
{
get;
set;
}
}
class MessyNullObjectVersion : SomeInterface
{
public void ChangeState() { throw new ApplicationException("Cannot set properties or change state of null objects."); }
public int SomeFunction(int arg) { return arg; }
public int SomeMethodWithSideEffect() { throw new ApplicationException("Cannot set properties or change state of null objects."); }
public int SomeProperty
{
get { return 0; }
set { throw new ApplicationException("Cannot set properties or change state of null objects."); }
}
}
class MaintainableNullObjectVersion : SomeInterface
{
public void ChangeState() { NullObjectHelper.Throw_InvalidToCallOrSetOnNullObject(); }
public int SomeFunction(int arg) { return arg; }
public int SomeMethodWithSideEffect() { NullObjectHelper.Throw_InvalidToCallOrSetOnNullObject(); }
public int SomeProperty
{
get { return 0; }
set { NullObjectHelper.Throw_InvalidToCallOrSetOnNullObject(); }
}
}
class NullObjectHelper
{
public static void Throw_InvalidToCallOrSetOnNullObject()
{
throw new ApplicationException("Cannot set properties or change state of null objects.");
}
}
The 'Messy' version will compile just fine, but the 'Maintainable' version will say something on the lines of 'SomeMethodWithSideEffect - not all code paths return a value'.
I have a hard time seeing how 'SomeMethodWithSideEffect' can avoid throwing an exception... Please explain.
--
Ubi Signo?
|
|
|
|
|
oh... I see now... The method SomeMEthodWithSideEffect() isn't actually throwing the exception, its calling another method to do that. I must have misunderstood what you were doing. The compiler doesn't know about the other method or that it only ever throws an exception, it just knows where it is to call it.
I would suggest that your NullOjectHelper does what it needs to do in order to construct the exeption and do the logging you need. Then return the exception object and you then throw it from where you need it. So your code becomes:
public int SomeMethodWithSideEffect()
{
throw NullObjectHelper.Throw_InvalidToCallOrSetOnNullObject();
}
class NullObjectHelper
{
public static Exception Throw_InvalidToCallOrSetOnNullObject()
{
return new ApplicationException("Cannot set properties or change state of null objects.");
}
} Then the compiler can see that an exception is being thrown.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Another good suggestion for a workaround.
Thanks!
Regards
/Joachim
--
Ubi Signo?
|
|
|
|
|
The problem ONLY exists in this line
public int SomeMethodWithSideEffect() <br />
{ NullObjectHelper.Throw_InvalidToCallOrSetOnNullObject(); }
as that method MUST return something. So another workaround is to have an overloaded helper
class NullObjectHelper { <br />
public static void Throw_InvalidToCallOrSetOnNullObject() <br />
{ throw new ApplicationException("Cannot set properties or change state of null objects."); <br />
} <br />
<br />
public static int Throw_InvalidToCallOrSetOnNullObject() <br />
{ throw new ApplicationException("Cannot set properties or change state of null objects."); <br />
} <br />
}
Then
public int SomeMethodWithSideEffect() <br />
{ return NullObjectHelper.Throw_InvalidToCallOrSetOnNullObject(); }
|
|
|
|
|
Another interesting suggestion. However, the compiler doesn't seem to allow overloads that differ in return type only. There has to be some parameter differences to make it work...
Thanks anyway.
Regards
/Joachim
--
Ubi Signo?
|
|
|
|
|
doh!! Course not... silly me!
|
|
|
|
|
Hi,
I want to convert the string which is in english to some other language like danish, italy...
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
You cannot convert the string in other languages. You just can change the format of the text including its indention. If you want to change the text, you have to store the text indifferent languages in some external file which may be a resource file and then read the text based on the current culture of the system.
Akif
|
|
|
|
|
PrakashBhaskar wrote: I want to convert the string which is in english to some other language like danish, italy
Then you need to hire a translator, or get a friend who can speak those languages to help.
CultureInfo knows nothing about these languages except that they exists. It is used to select the correct language resource, however, a human still has to define what the resources are for each language in which they are to be available.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Hi,
Thanks for your information.
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
So the basics of my app are completed, everything i'll need is complete (except directplay server) and it works, perfectly i might add. but it only works on MY computer whenever i try to run it on another it exits with a error code and a text saying: "Failed security policy check". if i try to run the app from my comp but from another computer's drive (via lan) the debbuger kick in and i get the above message+ "Unverifiable assembly". google had ssomething to say about the problem but i don't know how to implement the solution found there:
"A temporary method of solving this issue is to simply give the LocalIntranet
zone more trust. This can be done in the .NET Framework Configuration
control panel applet. A permanent solution is to modify your security policy
to give FullTrust to all assemblies signed with your key."
to the problem as stated there (which i think is my problem):
"If you're running (and remote debugging) your app from a local network
share, then I suspect that you're running into a permissions issue. Programs
that run on the CLR use something called code access security (CAS), which
assigns trust based upon evidence it can gather from the code itself. This
evidence is then compared against the security policy, and a permission
grant is generated."
anyway i'll be including the debug output when i run the app on another conputer, i hope that my post isn't too long and boring.
"'forms.exe': Loaded '\\Homepc\2games (d)\forms\Debug\forms.exe', Symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\mscoree.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\msvcr71.dll', Symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\assembly\NativeImages1_v1.1.4322\mscorlib\1.0.5000.0__b77a5c561934e089_49459abc\mscorlib.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorsn.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\urlmon.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\assembly\GAC\System\1.0.5000.0__b77a5c561934e089\System.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\assembly\NativeImages1_v1.1.4322\System\1.0.5000.0__b77a5c561934e089_70640dd3\System.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\assembly\GAC\System.Drawing\1.0.5000.0__b03f5f7f11d50a3a\System.Drawing.dll', No symbols loaded.
'forms.exe': Loaded 'C:\WINDOWS\assembly\NativeImages1_v1.1.4322\System.Drawing\1.0.5000.0__b03f5f7f11d50a3a_842e96f6\System.Drawing.dll', No symbols loaded.
The thread 'Win32 Thread' (0x1c0) has exited with code 0 (0x0).
'forms.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\diasymreader.dll', No symbols loaded.
'forms': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'forms': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'forms': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
An unhandled exception of type 'System.Security.Policy.PolicyException' occurred in Unknown Module.
Additional information: Unverifiable assembly '\\Homepc\2games (d)\forms\Debug\forms.exe' failed policy check.
The thread 'Win32 Thread' (0x218) has exited with code -532459699 (0xe0434f4d).
The program '[3192] forms.exe: forms' has exited with code 0 (0x0).
The program '[3192] forms.exe: Native' has exited with code 0 (0x0)."
m$: It is normal for your screen to go blank and for your computer to restart itself several times
|
|
|
|
|
You should start reading about CAS (code access security).
MSDN has some articles on the topic that will help you learn how your application behaves differently when run from an untrusted source (for example, a mapped network drive).
Regards,
mav
|
|
|
|
|
i don't really want to know how the app behaves i just want it to run, how can you make an untrusted source trusted so my program can run properly, i really need this program to run on just a couple of computers so modifying stuff would be posible but what do i need to modify?
i've read something realted to my problem but i have no ideea as to how i could generate the certificates required or integrate them inot my code
m$: It is normal for your screen to go blank and for your computer to restart itself several times
-- modified at 7:36 Tuesday 3rd January, 2006
|
|
|
|