|
Thanks Heath, but still not working -
Where would I add SecurityManager.SavePolicyLevel(machineLevel) call?
I tried adding it just before SavePolicy() call...
Just after SavePolicy() call...
In place of SavePolicy() call...
Still doesn't save the machine policy.
|
|
|
|
|
Compare it with this...which works:
NamedPermissionSet namedPS = new NamedPermissionSet("FullTrust");
PolicyStatement ps = new PolicyStatement(namedPS);
ps.Attributes = PolicyStatementAttribute.Exclusive;
string url = "http://www.dummycorp.com";
UrlMembershipCondition condition = new UrlMembershipCondition(url);
UnionCodeGroup proplanner = new UnionCodeGroup(condition, ps);
proplanner.Name = "MyCodeGroup";
proplanner.Description = "Allows fully-trusted access to the URL.";
PolicyLevel machine = null;
IEnumerator ie = SecurityManager.PolicyHierarchy();
while (ie.MoveNext())
if (String.Compare(((PolicyLevel)ie.Current).Label, "Machine", true) == 0)
machine = (PolicyLevel)ie.Current;
if (machine == null)
throw new InstallException("Unable to find the Machine policy level.");
bool exists = false;
foreach (CodeGroup group in machine.RootCodeGroup.Children)
{
if (proplanner.Equals(group))
{
exists = true;
break;
}
}
if (!exists)
{
machine.RootCodeGroup.AddChild(proplanner);
SecurityManager.SavePolicyLevel(machine);
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi there
I am having problems with loading my app at windows startup.
When i load my app by clicking on it, it works fine
but when i load it on windows startup, by adding a registry key in
HKLM\Software\Current Machine\Microsoft\Windows\Current Version\Run
it gives errors, the errors are of my files that i load when my app starts.
i have an xml file that i load when my app starts
that xml file has the location of my database file.
for now i store my db file where my app's executable is.
The code for my class :
using System;
using System.Xml;
using System.Xml.XPath;
namespace Scheduler
{
public class SettingsXml
{
XmlDocument doc = new XmlDocument();
public SettingsXml()
{
doc.Load("scheduler.xml");
}
public string DBPath()
{
string xstr = "/Scheduler/Configurations/DbPath";
XmlNode xnode = doc.SelectSingleNode(xstr);
return xnode.InnerText;
}
}
}
when the app loads at win startup it looks for my "scheduler.xml" file
in "c:\scheduler.xml" rather then the place i have told it to!
I fixed the "scheduler.xml" file's location problem by doing this:
doc.Load(System.Windows.Forms.Application.StartupPath + "/scheduler.xml");
It worked.
But still in my xml file the path of my db file is "scheduler.mdb"
now what do i do for this?
cause when i distribute my app it has to have some default place to place my db file.
What is the problem here?
VisionTec
|
|
|
|
|
visiontec wrote:
doc.Load("scheduler.xml"); // this means that this file // is where the app's .exe is
Unfortunately, no it doesn't. The file is tried in the current directory. The only reason why that works in your testing is because you launched the EXE from the folder by double clicking on it, thereby the current directory is the folder you double-clicked in.
When you launched the EXE from the Run key, the current directory is C:\, or one of the Windows directories, depending on what's going on. Your app is being launched with the full path to the EXE, but that doesn't make it the current directory.
To get around this problem, best-practice would be to code full path names into your app, but NOT hard-coded paths. Use configurable paths like:
StreamWriter sw = New StreamWriter(datapath + "\scheduler.txt");
You could also set the current directory when your app starts by using
Environment.CurrentDirectory = datapath;
But, best practice is to assume nothing! Don't assume that because you set the CurrentDirectory, that it is going to stay there!
EDIT:
Whoops! I supplied the code examples in VB, not C#. Rewrote for C# examples.
RageInTheMachine9532
|
|
|
|
|
Imagine this - I have two controls, one is simple usercontrol and the other is derived from System.Windows.Forms.Form.
Does any these controls have client area size different than the usual size of the control (Height and Width properties) ? Like - a form has a thick border around it, is the width of the border added to the Height property of the control ? Or when a usercontrol has a 3d border ?
I've heared a lot about nonclient area and stuff like that, where could I get more information about that ?
Regards, Desmond
|
|
|
|
|
The client area - which .NET exposes through common properties - does not include the border or the caption area. You can find more information about client and non-client areas in the Platform SDK at http://msdn.microsoft.com/library[^]. Look for the user interface section and find the Windows Controls and Windows Management API sections.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
is there a way i can get one of my programs to load when the ie explorer loads and when there is no explorer open to unload
thanks
chad
|
|
|
|
|
What do you mean exactly? You just want your app to start when iexplore.exe starts? A tried-and-true method would be to create a BHO (browser helper object) that simply executes your app, optionally passing a reference to the IWebBrowser2 interface or something similar.
You can find more about BHOs at http://msdn.microsoft.com/library/en-us/dnwebgen/html/bho.asp[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok how do i build a bho is csharp or do i have to use c++
thanks
chad
|
|
|
|
|
You can use C#, but you'll have to redeclare a bunch of interfaces and structs. You'd be better off writing it in C++ because it'll save you a lot of extra work since the interfaces and everything else you need are already defined in the headers mentioned in the documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have built my remotable object type (inherits from MarshalByRef). I have built my listener app, and a client app that instanciates the remotable type through the listener. All the examples I've seen online, including several on MSDN and a few on CP have done this.
My problem is that I want the host (listener) to instanciate the remotable type, then I want the client to modify that instance...and to be honest, I simply don't know how to do this.
If anyone can give me a quickie example or just point me in the right direction, I'd be very grateful.
---------------------------
He who knows that enough is enough will always
have enough.
-Lao Tsu
|
|
|
|
|
You should use a server-activated type - either a singleton or a single call object. If you want to learn more information about remoting, see http://www.ingorammer.com[^] and buy his book. It's presumed to be the best. Another good book is from MS Press[^] and is called "Microsoft .NET Remoting". And never forget to check the .NET Framework SDK[^]. Many examples are included in the documentation and related topics.
There's also other ways to create your object and get a reference to it using RemotingServices . .NET Remoting is a complicated technology and you should read about it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi! Guys,
I am a learner and new to .NET Technologies. I am creating a small application and want to include a facility for Backup.
The problem is, how to create a wizard which will guide the user for creating backup of database. Like, it will ask for path to store backup, other filteration criteria for data to take backup etc.
One approach can be to create a frame for each step and display them as per the user's choice (Back / Next).
Is this approach proper? What are the other possible ways?
Please, send in your suggestions and / or comments regarding this problem.
Thanking you,
Ritesh.
|
|
|
|
|
The most common method is to use a form and swap controls. If you've done any decent Win32 programming with the provided property sheet interfaces, you could design your classes like that, so that each page can tell their parent what they support.
You should search CodeProject using the Search text box at the top, and even this forum using the "Search comments" link directly above the message area. This has been covered many times in the past and many solutions have been discussed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
riteshsompura@yahoo.com wrote:
The problem is, how to create a wizard which will guide the user for creating backup of database. Like, it will ask for path to store backup, other filteration criteria for data to take backup etc.
Read the following article: TSWizard - a wizard framework for .NET[^]
- Nick Parker My Blog
|
|
|
|
|
Hi
I need to put a animation into my app, but I was wonderind what it's better use single frames and swap them with a timer or use a gif or avi directly (it's possible with .NET?)
Thanks
----
hxxbin
|
|
|
|
|
Depends on the quality of the animation and whether or not you want to require additional dependencies.
You could use a PictureBox to show an animated GIF, but GIFs only display 256 colors and don't support an alpha channel.
If you want to display an AVI or other video file, you could host the Windows Media Player control and hide its UI. Windows also contains an older version of this control but you may have problems finding information about it.
Another option is to use DirectX, for which there is now a managed runtime (aptly named Managed DirectX (9.0b)).
Finally, you could always use a timer and loop frames (basically what a GIF does). You can use a higher quality image this way, but your FPS are limited by the relatively low resolution of the timer classes in the .NET Framework.
Again, it all depends on what you want and how many dependencies you're willing to require.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The animation is little, but needs 24-bits color and alpha. I think I'll use the timer cuz I don't know how to use DirectX, I imagine that with DirectDraw2D I could do it, but I don't know how, you know some good info about??.
Thanks
----
hxxbin
|
|
|
|
|
|
When I call method from a custom ServicedComponent object from ASP.NET, I get the following exception:
?
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: ?
Note the question mark as the exception message.
Here is the stack trace:
InvalidCastException: ?]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +264
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +877
MyCOMPlusApp.MyInterface.MyMethod(String s1, String s2)
Intermediary method calls
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
The return value is a string.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
This information doesn't help at all. Stack traces are only helpful if you know the code that adds to the call stack. Since you provided none, it's pretty hard to help you. Why don't you provide some code in your Click event handler or something?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I thought this information could ring a bell on what may be a well-known issue. The problem is that I cannot post code because it is proprietary code. I will try to make an example with which i can reproduce this problem.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
I have more information, now I have a message instead of the question mark:
System.InvalidCastException: QueryInterface for interface MyApplication.IMyInterface failed
Here is how the Serviced component object is declared:
namespace MyApplication
{
[SecurityRole("MyAppClients")]
public interface IMyInterface
{
string MyMethod(string s1, string s2);
}
[ConstructionEnabled(true, Default="Server=(local);trusted connection=yes")]
[Transaction(TransactionOption.Supported)]
[ComponentAccessControl(true)]
[SecurityRole("MyAppClients")]
public class MyClass: ServicedComponent, IMyInterface
{
private string connectionString = String.Empty;
public MyClass()
{
}
protected override void Construct(string s)
{
this.connectionString = s;
base.Construct(s);
}
#region IMyInterfaceimplementation
public string MyMethod(string s1, string s2)
{
return "My String";
}
#endregion
}
When the application is registered in COM+, I add the MYMACHINE\ASPNET user to the role.
Here is how it is called from the Asp.NET client:
IMyInterface myInterface = new MyClass();
string aString = myInterface.MyMethod("s1", "s2"));
The exception is thrown at the second line.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
It's just a hunch since I don't have a lot of experience writing serviced components in .NET, but I have and do work a lot with COM interoperability. When exposing types to COM (as CCWs), you should follow the "rules" of COM, such as attributing your interfaces and classes with the GuidAttribute to give them specific IIDs and CLSIDs. These GUIDs and the interface declarations should never change after being published.
Since your QI is failing to get the interface, I'm figuring it's because the IID can't be resolved. When registering, this GUID is generated automatically unless explicitly specified.
I hope this helps.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Michel Prévost wrote:
IMyInterface myInterface = new MyClass();string aString = myInterface.MyMethod("s1", "s2"));
You should make sure you your cast were successful. I am not sure why it is failing but you definitely want to perform some error checking:
IMyInterface myInterface = new MyClass();
if(myInterface != null)
string aString = myInterface.MyMethod("s1", "s2");
- Nick Parker My Blog
|
|
|
|