|
|
can someone direct me to some good coding style guides..other then whats at msdn... thank you.
jesse M
The Code Project Is Your Friend...
|
|
|
|
|
|
|
I WANT make it clear that i dont want the highlighted code to run but it does, can make someone tell me why?
the permissions (intersecting all policy levels) for the assembly are unrestricted access to reflection. I checked it myself. I'm sure there is no mistake in the policy configurations
using System;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
[assembly:ReflectionPermissionAttribute(SecurityAction.RequestRefuse,Unrestricted=true, Flags = ReflectionPermissionFlag.AllFlags)]
namespace reflectsecuritytest
{
public class mo
{
public static void met( int i )
{
}
public static void met( float f )
{
}
public static void met( string s )
{
}
public static int met( decimal d )
{
return 1;
}
public static void met( object o )
{
}
public int i = 9;
public static int x = 2;
private int pr
{
get
{
return 2;
}
}
}
[
ReflectionPermissionAttribute(
SecurityAction.Deny,
Flags = ReflectionPermissionFlag.AllFlags,
Unrestricted = true
)
]
class Class1
{
public static void PermisosReflect()
{
ReflectionPermission sec =
new ReflectionPermission(
ReflectionPermissionFlag.AllFlags
);
try {
sec.Deny();
//*************************
//*************************
// *********************************
// the next code is supposed not to execute, but it does
//*************************
//*************************
//*************************
Type t = typeof( mo );
BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.Instance | BindingFlags.Static;
foreach( MemberInfo mi in t.GetMembers( bf ) )
{
Console.WriteLine( mi );
};
} catch( SecurityException e ){
Console.WriteLine( e );
}
}
public static void Deny()
{
Console.WriteLine("before calling");
ReflectionPermission sec =
new ReflectionPermission(
ReflectionPermissionFlag.AllFlags
);
sec.Deny();
PermisosReflect();
Console.WriteLine("after calling");
}
[STAThread]
static void Main(string[] args)
{
Deny();
Console.ReadLine();
}
}
}
|
|
|
|
|
Sorry i am new heer and didnt know how to post a message...so im just trying it out so Greetings all
|
|
|
|
|
Ρhoenix wrote:
Sorry i am new heer and didnt know how to post a message...so im just trying it out so Greetings all
You picked a bad spot to test if the site works ( which it obviously does, or there messages would not be here ), but welcome nevertheless.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Hi Phoenix,
You are welcome to try sending greetings and other test messages. But perhaps you are just out of the track. CodeProject has forums like Lounge etc, where you can post messages, that do not fit into Programming environments.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
IS there any clean solution to do that ? If you only use Windows Forms, the solution is 50% Clean by switching Language Property of Form ( much work...)
but what's about the text you use in your code, in your classes etc ? which way does microsoft provide, prefer ?
Any hints ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
The probably easiest way to handle strings is to add Assembly Resource Files (for each supported language 1) to your application. Then use a System.Resources.ResourceManager to read strings from the Resource file. When getting a string, the CurrentCulture is checked and the correct string is retrieved. Let me know if this helps or you need further assistence.
Matthias
You'll never master any language, except maybe VB, because there's nothing to it. (Lounge/Christian Graus)
www.mattbart.org Sonork ID: 100.32002
|
|
|
|
|
Hi,
thanks for your hint, but i still know this solution, but it's too complicated, i think. There must be a tool or something else to edit string resources, like
name lang1 lang2 lang3 etc..
and after you edit your resources, you click "Build", and you're resx files are builded. At this moment i'm checking out the "normal" way, but i guess that's no way i will follow.
Are there tools to build the resource files easy and fast ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
resgen seems to be tool to solve this. With resgen it's possible to extract resources to a text file from a resx file or binary resource file.
I will create a tool which use this features to edit my resources.
.:Greets from Jerry Maguire:.
|
|
|
|
|
I have a ResMan tool available off my site (GNU Public LIcense)...
Allows you to create / edit resx files. Supports text and images. Source code included.
http://www.ian-space.com/[^] (you do, however, have to register before you can download anything.
|
|
|
|
|
Hi,
I want to use DataSet and OleDbDataAdapter for manipulating some tables of a database. I know that when I want to do it for a table I can use below code:
<br />
{<br />
DataSet custDS = new DataSet();<br />
OleDbConnection myConn = new OleDbConnection(myConnection);<br />
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();<br />
myDataAdapter.SelectCommand = new OleDbCommand();<br />
myDataAdapter.SelectCommand.Connection = myConnection;<br />
<br />
OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);<br />
<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Customers";<br />
myDataAdapter.Fill(custDS, "Customers");<br />
<br />
<br />
myDataAdapter.Update(custDS, "Customers");<br />
<br />
}<br />
but when I want to use more tables I have, some problems:
<br />
{<br />
DataSet custDS = new DataSet();<br />
OleDbConnection myConn = new OleDbConnection(myConnection);<br />
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();<br />
myDataAdapter.SelectCommand = new OleDbCommand();<br />
myDataAdapter.SelectCommand.Connection = myConnection;<br />
<br />
OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);<br />
<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Customers";<br />
myDataAdapter.Fill(custDS, "Customers");<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Orders";<br />
myDataAdapter.Fill(custDS, "Orders");<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Products";<br />
myDataAdapter.Fill(custDS, "Products");<br />
<br />
<br />
myDataAdapter.Update(custDS, "Customers");<br />
myDataAdapter.Update(custDS, "Orders");<br />
myDataAdapter.Update(custDS, "Products");<br />
<br />
}<br />
Because the myDataAdapter only gives one SelectCommand and CommandBuilder generates some commannds for one of tables. So myDataAdapter.Update method works for one of tables.
Can anyone help me please? How can I use OleDbDataAdpter, DataSet and CommandBuilder to solve my problem?
|
|
|
|
|
mkomasi wrote:
OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);
myDataAdapter.SelectCommand.CommandText = "Select * from Customers";
myDataAdapter.Fill(custDS, "Customers");
myDataAdapter.SelectCommand.CommandText = "Select * from Orders";
myDataAdapter.Fill(custDS, "Orders");
myDataAdapter.SelectCommand.CommandText = "Select * from Products";
myDataAdapter.Fill(custDS, "Products");
You need to run the COmmandBuilder each time after you change your "select" statement. But then u have a problem with the Update (you will have to do the whole thing again). I recommend setting up a dataadapter for each table.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
hi @ll!
Is there any way to get a list of all computers in the network? (per C#)
thanks for any Ideas (I've got none
|
|
|
|
|
Hey I just did one (well a TypeCOnvertor for it)
private string pcname = ".";
[Category("Interface Options")]
[TypeConverter(typeof(ControlOptions.MachineConvertor))]
public string MachineName
{
get {return pcname;}
set {pcname = value;
sname = value;
}
}
[DllImport("Netapi32")]
private static extern int NetServerEnum(
string servername,
int level,
out int buffer,
int maxlen,
out int entriesread,
out int totalentries,
int servertype,
string domain,
int resumehandle);
[DllImport("Netapi32")]
private static extern int NetApiBufferFree(IntPtr ptr);
[StructLayout(LayoutKind.Sequential)]
class ServerInfo
{
public int platformid;
[MarshalAs(UnmanagedType.LPWStr)]
public string name;
public int majorver;
public int minorver;
public int type;
[MarshalAs(UnmanagedType.LPWStr)]
public string comment;
}
class MachineConvertor : TypeConverter
{
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
int eread, etot, buffer;
int l = 20;
int size = Marshal.SizeOf(typeof(ServerInfo));
int res = NetServerEnum(
null,
101,
out buffer,
size * l,
out eread,
out etot,
3,
null,
0);
int p = buffer;
ArrayList arr = new ArrayList(etot);
for (int i = 0; i < eread; i++)
{
ServerInfo si = Marshal.PtrToStructure((IntPtr) p, typeof(ServerInfo)) as ServerInfo;
arr.Add(si.name);
p += size;
}
res = NetApiBufferFree((IntPtr) buffer);
return new StandardValuesCollection(arr);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
I'v designed a custom control for myself, (so it's a dll) and anybody could use it , but i want it to be only for me! I have heard somethings about .key files but i don't know what r them!
|
|
|
|
|
Specify the licenseProvider to use by applying a LicenseProviderAtribute to your control's class.
Create the License file in accordance with the implementation of the LicenseProvider that you are using.
In the constructor of your control, call LicenceManager.Validate to validate your license.
Dispose of your license in the control's Dispose method.
Hope this is helpful.
Andy Harman
|
|
|
|
|
Hi!
A little puzzle...
You create a C# Windows Forms project.
You name your form 'frmClient'.
You add another form (with right click in solution explorer)
and name it 'frmClientDetails'.
The user, when using the 'frmClient', press the button 'btnClientDetails'.
This button close 'frmClient' and instanciate 'frmClientDetails', to let
the user fiddle with the clients details.
The question I have, is what is the code to provide this functionnality?
In VB6 (god forgive me) it was simple ...
Unload frmClient
frmClientDetails.show
In C#, It obviously a most erronous approach...
Ok, I know its kinda simple, I'm sure, but please,
help me out in this simple problem!
Thanks!
Orlanda
|
|
|
|
|
im not quiet sure what you are shooting for... but if the components on your second form are already intialized i.e MyRichTextBox = new RichTectBox(); try FormClient.Hide(); FormClientDetails.Show();
this will keep the form loaded and just simply hide it from the user ...
Jesse M
|
|
|
|
|
Hi !
How do I know if the components on the second are initialized ?
thanks!
;)
Orlanda
|
|
|
|
|
the formxxx.Handle property is not null
|
|
|
|
|
Here is the code, Jessy, for my main form, the one that was created with the project, and the one that loads first.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace PersonnaInterfaceSystem
{
///
/// Summary description for frmPISmain.
///
public class frmPISmain : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.PictureBox picLogo;
private System.Windows.Forms.Button btnQuit;
private System.Windows.Forms.PictureBox pictureBox9;
private System.Windows.Forms.PictureBox picContacts;
private System.Windows.Forms.PictureBox picPersonnaliser;
private System.Windows.Forms.PictureBox picCommunauté;
private System.Windows.Forms.PictureBox picCourrier;
private System.Windows.Forms.PictureBox picHoraire;
private System.Windows.Forms.PictureBox picSmithers;
private System.Windows.Forms.PictureBox picErendering;
private System.Windows.Forms.Button btn;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public frmPISmain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
hiden (too BIG!)
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new frmPISmain());
}
private void btnQuit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void btn_Click(object sender, System.EventArgs e)
{
frmPISmain.ActiveForm.Hide();
frmPISContact.ActiveForm.Show();
}
}
}
Heres the error I get!:
************************
An unhandled exception of type 'System.NullReferenceException' occurred in PersonnaInterfacceSystem.exe
Additional information: Object reference not set to an instance of an object.
************************
I just added another form with a right click, and then I just gave it some controls and what not. I just want to do the c# equivalent of VB's:
Unload form1
form2.show
hellllp!
Thanks,
;)
Me again
|
|
|
|
|
Anonymous wrote:
frmPISmain.ActiveForm.Hide();
frmPISContact.ActiveForm.Show();
the following would be better :
frmPISmain.Hide();
frmPISContact childForm = new frmPISContact();
childForm.Show();
|
|
|
|