|
I would like a place holder class btween my Screen Form and Windows Form. So, I create MyBaseForm class that inherits from System.Windows.Forms.Form. Then I create MYScreenForm class that inherits from MyBaseForm. However, at design time, I am not able to see the MyScreenForm. It gives the following error:
Request for the permission to type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeytoken=.... failed.
Thus, I am not able todesign my screen visually.
Note that I can place any controls programmatically and the code compiles and runs.
Appreciate any explanations / help
|
|
|
|
|
From where is your code running? A FileIOPermission is a code access security permission class that is granted, by default, to all code run from your machine. If your code is running from the intranet or Internet, it is granted even fewer permissions.
For a good overview of Code Access Security in .NET, read Understanding .NET Code Access Security[^] here on Code Project.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
The application is not even running!
This error occurs at design time in the Visual Studio. Both classes -- MyBaseForm and MyScreenForm -- are in the same project. In the Solution explorer I click on the MyScreenForm (which inherits from MyBaseForm) to view it in design mode in order to add some controls. Instead of showing the form, this error appears.
Thanks
|
|
|
|
|
But the code is running, actually. Notice that when you try to create an inheritted form VS.NET will complain if the assembly that contains the would-be parent form is not compiled yet?
If your target location for the assembly is on a network share, for example - even if the drive is mapped - you will most like get a SecurityException because the FileIOPermission isn't granted, by default, to anything but FullTrust code which is only given, by default, to the "My Computer" zone.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks Heath,
When I wrote "It is not even running" I meant I did not even execute. Yes, it is running.
The problem I am referring to occurs at design time - not at run time. Since I am not executing the code, I thought the IO error should not have occured. However, VS IDE probably is trying to execute the MyBaseForm code so as to display the form in design mode. So, this morning I changed the security to FullTrust - for the module that contains MyBaseForm. However, when tried to view MyScreenForm in design mode, it still did not work.
Request help.
Thanks once again.
Snnn
|
|
|
|
|
Again, the code is actually executing in design mode and serializes to a source file. Depending on what yo'ure trying to do an when, Code Access Security can prevent an application from running (it verifies that an application has the necessary minimal permission set) or from performing a certain action while running (if you demand a certain permission).
Please read that CAS article I posted in my previous reply.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks Heath for your reply.
I have gone through the CAS article you had suggested. It is very informative. However, I have to still go through it a couple of times before I can digest.
The impression I got is that CAS is for stopping unauthorized user to execute the code. However, the problem I have been facing is at design time. For the problem to be easily understood, I have created a small project. I am attaching a zip file of the project. This project successfully compiles. You can execute the same. But to observe the current problem, do the following:
Open the solution in VS 2003. This contains a Test project. This contains three forms - FrmMain, CSIBaseForm, FrmUser. FrmUser inhertis from CSIBaseForm which in turn inherits from System.Windows.Forms.Form. I double click on the FrmUser form to view it in design mode. It does not show.
Could you tell me what the problem is and what I should do to overcome it?
There does not seem to be a way of attaching the zip file here. I shall send it directly to your e-mail address.
Thanks.
|
|
|
|
|
I wish to find a general method for retriving fan's properties such as speed as well as CPU temperature, how could I go about doing it?
I tried to use win32_fan but it doesn't give me back anything.
|
|
|
|
|
Please post some sample code for how you used Win32_Fan. It's also possible that your drivers don't expose data correctly for the WMI class to view. You need to be sure your motherboard drivers are installed correctly and that they even expose the data you want. If they don't, there may be no practical way of getting it, short of knowing the details specs for the fan and writing assembler to get such information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
This is the coding I used... I work fine for other properties such as processor though.
ManagementObjectSearcher Fan = new ManagementObjectSearcher("Select * from Win32_Fan");
foreach(ManagementObject item in Fan.Get())
{
Text.WriteLine("<activecooling> {0} ",item.GetPropertyValue("ActiveCooling"));
Text.WriteLine("<description> {0} ",item.GetPropertyValue("Description"));
Text.WriteLine("<deviceid> {0} ",item.GetPropertyValue("DeviceID"));
Text.WriteLine("<name> {0} ",item.GetPropertyValue("Name"));
Text.WriteLine("<status> {0} ",item.GetPropertyValue("Status"));
Text.WriteLine("<variablespeed> {0} ",item.GetPropertyValue("VariableSpeed"));
Text.WriteLine("");
}
|
|
|
|
|
When you step through (debug) your code, do you get any results with Fan.Get() ? If not, then the problem is as I suspect: information about your CPU fan is not available.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I didn't get anything... I had tried with some other freeware program too but it didn't come up, perhaps it is like you said that the information is not available, however I had tried with several other computer and it didn't come up.... should I do programming on bios level or something like that?
Thank yah,
|
|
|
|
|
That may not help. The fan itself just may not provide any sort of metrics. I recommend you crack open the case, remove the fan carefully if necessary, and get any information off of it you can - like make, model, etc. See if you can find any hardware specs for it on the manufacturer's site before you start with low-level programming that 1) can be complicated, and 2) really isn't a job for .NET at this point. Sure, you could P/Invoke lots of APIs and define lots of structs and enums for interop, but 1) it would be specific to your fan (otherwise the Win32_Fan WMI class would probably give you what you need), and 2) may not work anyway because the fan itself doesn't provide metrics.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank a lot for your help...
Too bad that I am using a laptop and doesn't want to mess around with cracking it too much, I am really bad at assemble things back.
Thank you,
|
|
|
|
|
Ah, if it's a laptop I wouldn't recommend it. Most desktops are easy to open, often times with just the click of a button. Sorry.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have a simple Win Forms app that has a data grid on it. I have an access database with a Date/Time field in it that have values like 10/21/2004 10:32 PM. When the data is displayed in thr grid it comes out with just the date. I have tried adding a table style with the format specifier as {0:f} and {0:F} at design time and runtime with no change. I have done this same thing with SQL as the backend and have not had this problem. Has anyone else encountered this?
|
|
|
|
|
The DataGridTextBoxColumn.Format property takes a format specifier without the curly braces and without the indexer, so that you'd specify just "f" or "F". Read the documentation[^] for the property for more information.
If that doesn't work, make sure that the DataGridTableStyle.MappingName matches the DataTable
(or class name if binding against an array of types...just FYI) whether your set DataGrid.DataSource to a DataSet or a DataTable . It is far more robust, BTW, to bind a DataSet and set the DataGrid.DataMember to the table name.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for the info. Changing the format specifier to just f do not fix it, but your suggestion for the mapping name did the trick. Thanks!
|
|
|
|
|
|
Can you explain what you mean by a "UI thread" please?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
User Interface thread. Not Worker thread.
|
|
|
|
|
Alex_Y wrote:
User Interface thread. Not Worker thread.
When you create a Windows Forms application and run it, it always has a UI thread. Otherwise your application wouldn't be able to handle any UI-related events (see also Multithreaded Windows Forms Control Sample[^]). Besides having a message queue[^] and owning windows[^] it is just a normal thread and you should normally not need to create another thread with a message pump (although it is possible by calling Application.Run()[^]). If you want to manipulate the UI from a thread other than the UI thread to need to marshal the call to the UI thread (see Updating the UI from a Secondary Thread[^]).
Best regards
Dennis
|
|
|
|
|
I am little confused. How I can use resources in C#. I want to have some file where like in *.rc I can put all my strings. I do delopment for several languages.
Thanks
Alex.
|
|
|
|
|
.NET uses .ResX files by default, but the system is flexible and extensible. I encourage you to read Resources in Applications[^] in the .NET Framework SDK. This explains how to create .ResX files (XML files, which can also describe more than just strings by any string-convertible type), compile them (resgen.exe), and use them (the ResourceManager class, or a derivative).
You should also read Working with Resource Files[^] in the Visual Studio .NET product documentation that describes how VS.NET makes it easy to localize your libraries and applications.
Some improvements are being made for Visual Studio 2005. Read my blog entry[^] for details.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks. I just thought that there is something which build in IDE like resource view in VS6.
Thanks.
Alex
|
|
|
|