|
His project and NT security have nothing to do with it. It's .NET Code Access Security, which is a feature of the CLR.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The Common Language Runtime (CLR) features Code Access Security - a sandbox environment for .NET, if you will. By default, applications executed from the network (or that use network resources) run without FullTrust permissions. They are limited in what they can do, and local file access is restricted, among many other things.
I suggest you first read Understanding .NET Code Access Security[^]. You need to either change the Intranet permission set (not recommended), or create a new CodeGroup that uses a membership condition that will match up with your host or assembly evidence that the CLR would grab (like using a Url membership condition with "file://MYNETSERVER/SOMESHARE/*"). Grant that either FullTrust permissions (not recommended; do things right) or the necessary permissions to run.
To help administrators know what permissions your code requires, you should attribute your assembly with certain permission requirements (assembly-level attributes). You should also be mindful that your code may not be granted optional permissions and should check for SecurityException s accordingly (by either catching potential cases, or asserting the permission to see if you can perform a certain action).
For that, read Securing Applications[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
or create a new CodeGroup that uses a membership condition that will match up with your host or assembly evidence that the CLR would grab (like using a Url membership condition with "file://MYNETSERVER/SOMESHARE/*"). Grant that either FullTrust permissions (not recommended; do things right) or the necessary permissions to run.
Yikes, I've read through the article a few times and still don't quite see what you mean by this. Some of these follow-up questions are probably still due to my misunterstanding but here they are none the less.
Can I just grant the program the "fulltrust" or permissions it needs no matter where it's being run from? Cause the file could be run from anywhere on our network. Not a specific location, I just can't seem to figure out how to do this? Is it an assembly directive?
It seems like creating a codegroup is just for the local machine and not everyone which is bad for 100+ people that would be running this.
P.S. I added:
[assembly:FileIOPermission(SecurityAction.RequestMinimum, Write="C:\\")]
To at least throw an exception when it can't do what it needs to do, I just have no clue how to handle the exception. (Where does it throw to?)
This is really wild stuff, Thanks for taking the time to help explain it.
|
|
|
|
|
An application can only tell the CLR what it needs to run. It can't grant itself permissions; that would defeat the purpose. Do you trust someone just because they say they're trustworthy? I certainly don't.
If you use an assembly-level permission attribute, the assembly is not even executed so you can't handle an exception (unless you're a different assembly trying to use a type defined in that assembly, when it's loaded for the first itme - you really have to understand how the CLR works).
You can grant your assembly or assemblies FullTrust permission (again, that's a big cop-out and not a very good idea) if you use assembly evidence to match up with membership conditions for a code group. Assembly evidence is strong name identity evidence and publisher (x.509) evidence. If you add a CodeGroup using either of those membership conditions, then your assembly will be granted whatever permission set you choose. If you use host-based evidence like URLs or site, then an assembly matching that evidence will be granted those permissions.
A codegroup is installed into a machine's policy, yes, which is why you have to install it onto all machines. This is no different that ActiveX security (what little there is) policies and Java sandbox policies. This can be distributed through Windows Installer packages, batch files, start-up scripts, whatever. Distributing a policy is not hard if you no what you're doing.
Don't just read the article; read the other links I gave you as well. The article here on CodeProject explains Code Access Security, but there's more information about setting up code groups and why.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
about Ado.net.When get data from database, use dataset or datareader which is faster?
|
|
|
|
|
A DataSet is used to store data not extract it from the database. However the operation to fill a DataSet uses the DataReader to get the information from the database. The DataReader is a Read-Only Forward-Only mechanism to get information out of the database.
The two are not directly comparable, it depends on what you want to do with the data. However, if all you want to do is read the data quickly then the DataReader is your best choice.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
I found out when loading some images into imagelist,then using these images in Application, as a result these images's quality are very bad.but I using Image.FormFile(strFilename), these are normal.Why? do i should do it?
|
|
|
|
|
Is the "ColorDepth " property of your imagelist set to "Depth32Bit "? If not, then set it to that value and see if that fixes the problem.
Happy Programming and God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
The ImageList control, not the .NET class, but the ImageList control it wraps, has a bunch of problems. I would suggest you try to avoid using the control if you can.
But, the problems depends on what other controls your using the ImageList with, such as a TreeView getting it images from an Imagelist, and/or the types of file your loading into the ImageList. For instance, the Imagelist has problems with certain types of images using an alpha channel.
So you'll have to be a bit more specific about the problem so we can suggest a fix or workaround. What kind of problems are you having specifically? Do they involve using the ImageList supplying images to other controls?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm not very experienced in .NET Remoting technology. I wrote some simple demos involving that aspect.but I found the client side must reference the server side so that the Activator can create the stub of the server object. when we distribute the application, we have to place a copy of server assembly along with client side.
A copy of server object along with client means Remoting? I think it should not like that, but I don't quite understand.
Then in general, what's the correct way to develope and distribute a .NET remoting application?
Thanks.
|
|
|
|
|
Yes, that's right. You have to reference the library that implements the server objects from the client side. I think it is similar to COM+ (or DCOM) where you have to install the type library on the client machine.
I hate this, too, that's why I prefer web services to remoting. However, I am no expert on .NET remoting.
My articles and software tools
|
|
|
|
|
Then you might want to do it right. You do not have to reference the server code, only the interface that the Remoting object implements. So, either define the interface that the server object implements in a shared assembly, or use soapsuds.exe to create a client-side proxy.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
You do not have to reference the server code, only the interface that the Remoting object implements.
But that is still a pain, don't you agree? With web service, I only care about the interface of the web method I am calling. Also, I can use web methods in non .NET programs or non windows platforms.
My articles and software tools
|
|
|
|
|
I'm afraid I don't understand the point you're trying to make. Personally, I don't think it's hard at all - in fact, I'd rather link against the same interface for type safety and resolution. But the original question doesn't deal with ease, only how to do what the poster was wanting.
As far as a shared interface between web services and remoting, it's really don't different. The biggest difference is that with web services you can create a similar interface, where with .NET remoting the Type of the interface almost always has to be the same (there are tricks around this).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
I'm afraid I don't understand the point you're trying to make. Personally, I don't think it's hard at all - in fact, I'd rather link against the same interface for type safety and resolution. But the original question doesn't deal with ease, only how to do what the poster was wanting.
You are right, it is not hard and my point (if I have one) is not very closely related to the original question.
However, in the original post the poster does show his "frustration" that he has to deploy a server dll on the client side. This server dll may contain only the interface not the implementation details, as pointed out by you and others. My point is, using web service you don't have to do this and there are other advantages of using a web service.
[Edit]
Here is an example to demonstrate the "pain" I am talking about. Supppose the remote object has 3 methods and it is used by mutiple client applications running on remote machines.
The clients and the server are closely tied by the shared dll that contains the interface of the remote object. If you add another method to the remote object which is needed by only one new client, then all the clients have to be recompiled with the new version of the shared dll.
[/Edit]
My articles and software tools
|
|
|
|
|
Xiangyang is wrong. You don't have to reference the implementation dll. Check out an example of how to use a proxy share dll here.
http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=RemoteObject
|
|
|
|
|
I saw that article of
http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=RemoteObject [^]
Basicly it's approach is that the client and server both reference a abstract class ,from which the server side object inherites. while the client side can also activate the real descendant object by knowing it's parent type.
This is quite a elegant way.
Thank you and Xiangyang.
|
|
|
|
|
Allen Anderson wrote:
Xiangyang is wrong. You don't have to reference the implementation dll. Check out an example of how to use a proxy share dll here.
A proxy share dll is somewhat similar to a type library in COM+, right? In that case, I am not completely wrong.
My articles and software tools
|
|
|
|
|
[ToolboxBitmap(typeof(myNamesapce.myControl), "myNamespace.FlatComboBox.bmp"]
How can i change the icon defaul of the custom control
Thanks
Rock Throught The Night
|
|
|
|
|
You might start by reading about the ToolboxBitmapAttribute . The reason you include the Type is to provide a namespace in order to resolve the bitmap.
Just attribute your control with:
[ToolboxBitmap(typeof(myNamespace.myControl), "FlatComboBox.bmp")] "myNamespace" is grabbed from the Type and prepends the filename to find the embedded resource. Make sure you change the Build Action in VS.NET for the "FlatComboBox.bmp" to "Embedded Resource" and that it is contained in your project with the root namespace set to "myNamespace", or in a folder which is used to generate the namespace for embedded resources (and used for the default namespace for new source files, although you can change it).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know that this is possible.
internal static string ByteArrayToHexString( byte[] buf )
{
StringBuilder sb = new StringBuilder( buf.Length );
for ( int i = 0; i != buf.Length; ++i )
{
sb.Append( buf[i].ToString( "X2" ) );
}
return ( sb.ToString() );
}
But I found this code in the BCL and was just trying to
make it work. The trouble I am having is in the lowwer
while loop. From what I can see is it is supposed to index
into the s_acharval array that contains the valid hex
digits. But I have had no luck in figuring it out.
internal unsafe static string ByteArrayToHexString( byte[] buf, int iLen )
{
char[] chs1 = s_acharval;
if ( chs1 == null )
{
chs1 = new char[16];
int i = (int)chs1.Length;
while ( --i >= 0 )
{
if ( i < 10 )
{
chs1[i] = (char)( 48 + i );
}
else
{
chs1[i] = (char)( 65 + ( i - 10 ) );
}
}
s_acharval = chs1;
}
if ( buf == null )
{
return null;
}
if ( iLen == 0 )
{
iLen = (int)buf.Length;
}
char[] chs2 = new char[(uint)(iLen * 2)];
fixed ( char* ch1 = &chs2[0])
{
fixed ( char* ch2 = &chs1[0])
{
fixed ( byte* b1 = &buf[0] )
{
char* ch3 = ch1;
byte* b2 = b1;
while ( --iLen >= 0 )
{
*ch3++ = *( ch2 + ( 2 * (( *b2 & 240 ) >> 4 )));
*ch3++ = *( ch2 + ( 2 * ( *b2 & 15 )));
b2++;
}
}
}
}
return new String( chs2 );
}
Any help would be greatly appreciated.
Thank You
Bo Hunter
|
|
|
|
|
So what exactly are you trying to figure out? If you don't understand how the code works, I suggest you first read-up on the fixed statement (which pins an object in memory, preventing it from being relocated by the GC). The rest is simple pointer math.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I should have been more pacific.
What I ment by the part I am having
trouble with is the last while loop
is it does not work.
These lines are the problem.
*ch3++ = *( ch2 + ( 2 * (( *b2 & 240 ) >> 4 )));
*ch3++ = *( ch2 + ( 2 * ( *b2 & 15 )));
b2++;
What I am going by is the hash returned for a
certain byte[] does not match the result from
the same function with the same byte[] in the BCL.
Thank You
Bo Hunter
|
|
|
|
|
"Specific". "Pacific" is the worlds largest ocean.
Also, sayinging "it does not work" doesn't help me one bit. What doesn't work? Be more specific. Do you tell your doctor that you don't feel well and leave it at that?
A byte is a byte is a byte. A byte is 8 bits (currently; I doubt that will ever change). On some platforms, these are big endian and some art little endian, but the .NET Framework takes care of that detail for you.
Whatever the case is, the BCL is correct. If you don't understand pointer math, I suggest you just use byte.ToString("x2") ; otherwise, please be more specific about what the problem is. I - or any other regular here - am not going to debug your code for you, but we'll try to help you if you be more specific and tell us what's wrong.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You know something Heath; don’t answer any more of my post.
You have a big chip on your shoulder.
I have never seen you correct someone's
Spelling before, all you are doing is being a smart ass.
It is because of me posting some of your previous posts when you
start bashing people for not doing this and not doing that.
What is your problem? I could understand that being
vague or something but to start a post with
("Specific". "Pacific" is the world’s largest ocean.)
Is nothing more than the arrogant, self absorbed, inconsiderate
prick that you are.
Now did I misspell anything this time?
This is what Heath Stewart thinks about Certifications.
Heath Stewart said
"Personally, I am not certified because I really don't want to be. I know a large number of people with certifications that know crap. They studied for the tests, memorized a few things, took the tests (sometimes a couple times) and got their certs. They're still idiots."
|
|
|
|