views:

297

answers:

1

Hi

I have declared an object in my global.asax file as follows.

<object Id="WFRuntime" RunAt="Server" Class="System.Workflow.Runtime.WorkflowRuntime" Scope="application">

While I'm able to access this object within the global.asax file methods, I'm not able to use it elsewhere in the asp.net web application. I'm using .net 3.5 framework.

Any directions?

Thanks, Socratees.

A: 

First, ensure that your Global.asax file has a code-behind

<%@ Application Codebehind="Global.asax.cs" Inherits="YourSite.Global" Language="C#" %>

If you don't have one, create a Global.asax.cs file. This must be in your App_Code directory if you have a Web Site instead of a Web Project. It must look something like this:

namespace YourSite {
    public class Global : HttpApplication {
        public System.Workflow.Runtime.WorkflowRuntime WFRuntime { get; set; }
    }
}

That should make it so all pages in your site can reference ((Global)Context.Application).WFRuntime.

Alternatively, you could make the WFRuntime member static and then just use "Global.WFRuntime" throughout your site.

Andrew Arnott