简体   繁体   English

是否可以在.net 1.1和.net 4.0应用程序之间共享应用程序数据

[英]Is it possible to share Application data between .net 1.1 and .net 4.0 applications

The question(s) might be silly because i donot have much knowledge about framework 1.1 这个问题可能很愚蠢,因为我对框架1.1的了解不多

I'm trying to share the Application level variable among two different .net applications. 我正在尝试在两个不同的.net应用程序之间共享应用程序级别的变量。 one is .net 1.1 and the other is .net 4.0. 一个是.net 1.1,另一个是.net 4.0。

Here is the scenario: 这是场景:

I've created an application( App11 ) which targets .Net Framework 1.1 using Visual Studio 2003. I've also created a web site( App40 ) which targets .Net Framework 4.0 in Visual Studio 2010. 我已经使用Visual Studio 2003创建了一个针对.Net Framework 1.1的应用程序( App11 )。我还创建了一个针对Visual Studio 2010中的.Net Framework 4.0网站( App40 )。

I've added the App40 in the App11 , i've hosted App11 in IIS 5.1. 我已经添加了App40App11 ,我已经主持App11在IIS 5.1。 Now App40 is a folder in App11 . 现在App40是一个文件夹App11

App40 has the application pool with framework 4.0 and App11 has the application pool with framework 1.1. App40具有带有框架4.0的应用程序池,而App11具有带有框架1.1的应用程序池。

I donot have much of knowledge in .Net Framework 1.1 . 我对.Net Framework 1.1不太了解。 So,i've google and found state management techniques for .Net Framework 1.1 . 因此,我在Google上找到了.Net Framework 1.1的状态管理技术 It seems like Framework 1.1 supports Application State 似乎Framework 1.1支持应用程序状态

I thought the Application management would work. 我认为应用程序管理会起作用。 So, i've tried like this: 所以,我已经试过像这样:

In the App11 í've defined a Application variable in the Application_Start() of Global.asax . App11已在Global.asaxApplication_Start()中定义了一个Application变量。

protected void Application_Start(Object sender, EventArgs e)
        {
            Application["AppDATA"]="Application Data";
        }

I've a Default.aspx page in App11 application. 我在App11应用程序中有一个Default.aspx页面。 The Default page has a hyperlink to redirect to the App40/Default.aspx page. “默认”页面上有一个超链接,可重定向到App40/Default.aspx页面。

In the Codebehind file of Default.aspx in App40 i've done like this: App40Default.aspx的Codebehind文件中,我这样做如下:

//Application State check
        if (Application["AppDATA"] != null)
        {
            applicationState.Text = "Got application state data :"+Application["AppDATA"].ToString();
        }
        else
        {
            applicationState.Text = "Application State failed to work !";
        }

I've builded both the applications and stated with Default page of App11 . 我已经构建了两个应用程序,并在App11 Default页面中进行了App11

When i click on the link i could not see any Application data that has come from the Framework 1.1, it only shows Application State failed to work ! 当我单击链接时,我看不到任何来自Framework 1.1的应用程序数据,它仅显示Application State failed to work !无效Application State failed to work ! message on the page. 页面上的消息。

Does this work ? 这行得通吗? or Am i trying these things stupid ? 还是我尝试这些愚蠢的事情?

Do i need to setup anything in addition to the things i've done ? 除已完成的工作外,我是否还需要设置其他任何内容?

As far as I see it, your application level variables are on application level, so if you have 2 different applications it seems quite logic they're not sharing variables. 据我所知,您的应用程序级变量位于应用程序级,因此,如果您有2个不同的应用程序,则看起来很逻辑,它们不共享变量。 I think you need to use a file , a database or even a webservice to share data among different applications... 我认为您需要使用文件,数据库甚至Web服务在不同应用程序之间共享数据...

No, you cannot just simply share data between your specified applications (at least that's what I know). 不,您不能仅在指定的应用程序之间共享数据(至少我知道这一点)。

You would need to store data to an external place like an XML file. 您将需要将数据存储到XML文件等外部位置。 One application would write the data to the file, and other can read it. 一个应用程序会将数据写入文件,其他应用程序可以读取它。 Or you can make both of them do the same thing. 或者,您可以让他们两个做同一件事。

You can also use a database to store the data. 您还可以使用数据库来存储数据。 This would also work like I mentioned with a XML file. 这也可以像我提到的XML文件一样工作。

I hoped I helped. 我希望能有所帮助。

It's not possible to do it the way you are trying. 无法按照您尝试的方式进行操作。 Unlike Session state which has different modes (in memory, sql, session server) Application state is always stored in memory . 与具有不同模式(在内存,sql,会话服务器中)的会话状态不同,应用程序状态始终存储在memory中 Applications in different application pools run in different processes, so it's not possible to directly share this information. 不同应用程序池中的应用程序以不同的进程运行,因此无法直接共享此信息。 You'll need to store the data in one process and use some kind of IPC. 您需要将数据存储在一个过程中,并使用某种IPC。 There are many possibilities: SQL, Remoting, WCF, web service, etc. 有很多可能性:SQL,远程处理,WCF,Web服务等。

Note that even if they were in the same application pool they wouldn't automatically share Application state, since they would be running in different App Domains. 请注意,即使它们位于同一应用程序池中,它们也不会自动共享应用程序状态,因为它们将在不同的App Domain中运行。 But without the OS isolation, it would be easier to share between them. 但是,如果没有操作系统隔离,它们之间的共享将更加容易。

您要在应用程序之间共享状态的唯一方法是某种持久性(数据库,cookie,查询字符串...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM