c# - "Use of unassigned local variable" error with an Interface -


I have trouble with some syntax. I am not really familiar with the interface so please seduce my ignorance.

The VS2010 is giving me an error ... application.Name = System.AppDomain.CurrentDomain.FriendlyName; Public static Zero AddApplication (String Application Name = Zero, String Process ImageFilename = Zero) {INetFw Authorized Application Application; INetFw Authorized Application Application; If (applicationName == tap) {application.Name = System.AppDomain.CurrentDomain.FriendlyName; / * Set the name of the application * /} and {application.Name = applicationName; / * Set the name of the application * /} if (processImageFileName == zero) {application.ProcessImageFileName = System.Reflection.Assembly.GetExecutingAssembly (). place; / * Set this property in place of the application's executable file * /} and {application.ProcessImageFileName = processImageFileName; / * Set this property to the executable file of the application * /} application. Competent = true; // Enable it * Now Add / Type this application to the authorized app collection * Netfgroup = Type. Gettypefrumprogid ("Hntcfg. FMGR", false); INETFwMgr MGR = (INetFwMgr) catalyst. Createinstance (networkfgroup type); Application = (INetFw Authorized Application) mgr.LocalPolicy.CurrentProfile.AuthorizedApplications; Applications.Add (application); }

I can set this error to application to null , but it causes the run-time blank reference error .

Edit:

From where I am optimizing the code, I hope that it gives more context

You never start

  application   

Before using it here:

  application.Name = System.AppDomain.CurrentDomain.FriendlyName;   

The variable application is defined:

  INetFw Authorized Application Application   

An example of a class Applying which interface INetFw authorized application applies.

Any class of public class: INETFw authorized application {/ / ...} Public Class Other Class: INETFw Authorized Application {// ...}

You need to determine which class you should use (some classes, Other class) assign a proper object, eg such as:

  INetFw authorized record RUSSY APPLICATION = New Class ();    

Comments