2个项目共享1组文件 [英] 2 Projects Sharing 1 Set of Files

查看:76
本文介绍了2个项目共享1组文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个解决方案,其中包含1个桌面组件和1个组件

用于Pocket PC。 (虽然这不是一个移动问题)。


我有一个将在两个平台上共享的数据库。所以我已经采用了让两个项目共享同一组文件的方法。在

我的情况下,我有两个同样命名的项目:

DataObjects

DataObjectsCF


前者用于桌面应用程序,后者用于Compact Framework。


在这两个项目共享的许多类中,我有一些

条件编译语句看起来像这样:

#if(CF)


其中''CF''用于表示仅用于Pocket PC的代码,反之为

''!CF''仅用于桌面的代码。


我打开了DataObjectsCF的属性并添加了条件

编译常量''CF''。奇怪的是,这处理了所有文件

看着就像我在调试Pocket PC应用程序一样,当

显然我正在使用桌面应用程序时。


为什么会这样?


-

Robert W.

温哥华,BC
www.mwtech.com

I''m building a solution that has 1 component for the Desktop and 1 component
for the Pocket PC. (Though this isn''t a mobile question).

I have a data library that will be shared on both platforms. So I''ve
adopted the approach of having two projects share the same set of files. In
my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact Framework.

Throughout the many classes shared by these two projects I have some
conditional compilation statements that look like this:
#if (CF)

where ''CF'' is used to denote code only for the Pocket PC and conversely
''!CF'' is for code only for the Desktop.

I opened up the properties of DataObjectsCF and added the conditional
compilation constant ''CF''. Strangely though, this treated all the files
"looked at" by DataObjects as if I were debugging the Pocket PC app, when
clearly I was working with the Desktop app.

Why is this?

--
Robert W.
Vancouver, BC
www.mwtech.com

推荐答案

存在问题(至少我把它分类)如果你有两个

项目,在同一个解决方案中,链接到同一个文件,那么当

那个文件是打开加载到解决方案中的最后一个项目

优先于其他项目,这个

项目的条件常量将被识别以及智能感知基于显示信息

加载的最后一个项目的引用。简而言之,如果您在同一解决方案中的项目之间共享文件

,并且一个项目的目标是完整的

框架,而另一个项目则针对紧凑框架,那么你可能会看到问题,因为在这种情况下似乎就是这种情况。唯一的解决方法

我知道的是将每个项目放入自己的解决方案中。这不是很好,但它比处理共享文件的幻像问题更好。

您的情况中的另一个选择是编码和编译,你的类

库对抗紧凑的框架,只使用紧凑的框架类

也存在于完整的框架中,并且类库将是可用的
$桌面上有b $ b,因为它可以重新定位。


-

Tim Wilson

..NET Compact Framework MVP


" Robert W." <滚装***** @ discussions.microsoft.com>在消息中写道

新闻:ED ********************************** @ microsof t.com ...
There is an issue (at least I classify it as such) where if you have two
projects, in the same solution, that are linking to the same file, then when
that file is open the last project that was loaded into the solution will
take precedence over the others and the conditional constants for this
project will be honored as well as intellisense showing information based on
the references of the last project loaded. In short, if you''re sharing files
between projects in the same solution, and one project is targeting the full
framework while the other is targeting the compact framework then you may
see issues, as it appears is the case in this situation. The only workaround
that I''m aware of is to place each project into its own solution. It''s not
nice but it''s better than dealing with the phantom issues of shared files.
The other option in your situation is to code, and compile, your class
library against the compact framework, using only compact framework classes
that also exist in the full framework, and the class library will be usable
on the desktop as it is retargetable.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:ED**********************************@microsof t.com...
我正在构建一个解决方案,其中包含1个桌面组件和1个
组件,用于Pocket PC。 (虽然这不是一个移动问题)。

我有一个将在两个平台上共享的数据库。所以我采用了让两个项目共享同一组文件的方法。
就我而言,我有两个同名的项目:
DataObjects
DataObjectsCF

前者用于桌面应用程序,后者用于Compact
框架。
在这两个项目共享的许多类中,我有一些
条件编译语句,如下所示:
#if(CF)

where' 'CF''用于表示仅用于Pocket PC的代码,反之为'!''CF''仅用于桌面的代码。

我打开了DataObjectsCF的属性和添加了条件
编译常量''CF''。奇怪的是,这处理了所有文件
看着通过DataObjects就好像我在调试掌上电脑应用程序一样,显然我正在使用桌面应用程序。

为什么会这样?

-
Robert W.
BC省温哥华
www.mwtech.com
I''m building a solution that has 1 component for the Desktop and 1 component for the Pocket PC. (Though this isn''t a mobile question).

I have a data library that will be shared on both platforms. So I''ve
adopted the approach of having two projects share the same set of files. In my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact Framework.
Throughout the many classes shared by these two projects I have some
conditional compilation statements that look like this:
#if (CF)

where ''CF'' is used to denote code only for the Pocket PC and conversely
''!CF'' is for code only for the Desktop.

I opened up the properties of DataObjectsCF and added the conditional
compilation constant ''CF''. Strangely though, this treated all the files
"looked at" by DataObjects as if I were debugging the Pocket PC app, when
clearly I was working with the Desktop app.

Why is this?

--
Robert W.
Vancouver, BC
www.mwtech.com



Tim,


感谢您的回复。因为所谓的幽灵问题,我认为你已经敲了敲头。

好像正是我现在正在经历的
。他们很可怕!


关于你的后一个想法,如果我只是编码

CF的所有内容,那么我会手动复制结果DLL进入WinForms项目?

换句话说,如何强制类库总是为CF编译?


-

Robert W.

温哥华,不列颠哥伦比亚省
www。 mwtech.com


" Tim Wilson"写道:
Tim,

Thank you for your response. I think you''ve hit the nail on the head
because so-called "phantom issues" seem to be exactly what I''m experiencing
now. They''re scary!

With regard to your latter idea, if I were just to code everything for the
CF then I would manually copy the resultant DLL into the WinForms project?
Put another way, how do I force a class library to always compile for the CF?

--
Robert W.
Vancouver, BC
www.mwtech.com

"Tim Wilson" wrote:
有一个问题(至少我将其分类)如果你有两个
项目,在同一个解决方案中,链接到同一个文件,然后当该文件打开时,加载到解决方案中的最后一个项目将优先于其他项目,并且该项目的条件常量将被尊重以及智能感知显示信息基于
最后一个项目的引用。简而言之,如果您在同一解决方案中的项目之间共享文件,并且一个项目针对完整的框架,而另一个项目针对紧凑框架,那么您可能会看到问题,在这种情况下似乎就是这种情况。我知道的唯一解决方法是将每个项目放入自己的解决方案中。它不是很好但是它比处理共享文件的幻像问题更好。
您的情况中的另一个选择是编写和编译您的类
库对于紧凑的框架,只使用完整框架中也存在的紧凑框架类,并且类库可以在桌面上使用,因为它是可重定向的。

- -
Tim Wilson
.. NET Compact Framework MVP

Robert W. <滚装***** @ discussions.microsoft.com>在消息中写道
新闻:ED ********************************** @ microsof t.com。 ..
There is an issue (at least I classify it as such) where if you have two
projects, in the same solution, that are linking to the same file, then when
that file is open the last project that was loaded into the solution will
take precedence over the others and the conditional constants for this
project will be honored as well as intellisense showing information based on
the references of the last project loaded. In short, if you''re sharing files
between projects in the same solution, and one project is targeting the full
framework while the other is targeting the compact framework then you may
see issues, as it appears is the case in this situation. The only workaround
that I''m aware of is to place each project into its own solution. It''s not
nice but it''s better than dealing with the phantom issues of shared files.
The other option in your situation is to code, and compile, your class
library against the compact framework, using only compact framework classes
that also exist in the full framework, and the class library will be usable
on the desktop as it is retargetable.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:ED**********************************@microsof t.com...
我正在构建一个解决方案,其中包含1个桌面组件和1个
I''m building a solution that has 1 component for the Desktop and 1


组件

,用于Pocket PC。 (虽然这不是一个移动问题)。

我有一个将在两个平台上共享的数据库。所以我采用了让两个项目共享同一组文件的方法。
for the Pocket PC. (Though this isn''t a mobile question).

I have a data library that will be shared on both platforms. So I''ve
adopted the approach of having two projects share the same set of files.


我的情况下,我有两个同样命名的项目:
DataObjects
DataObjectsCF

前者适用于桌面应用程序,后者适用于Compact
my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact


Framework。


Framework.


在这两个项目共享的许多类中,我有一些如下所示的条件编译语句:
#if(CF)

其中''CF' '用于表示仅用于Pocket PC的代码,反之为'!''CF''仅用于桌面的代码。

我打开了DataObjectsCF的属性并添加了条件
编译常量''CF''。奇怪的是,这处理了所有文件
看着通过DataObjects就好像我在调试掌上电脑应用程序一样,显然我正在使用桌面应用程序。

为什么会这样?

-
Robert W.
BC省温哥华
www.mwtech.com




>关于你的后一个想法,如果我只是为
> With regard to your latter idea, if I were just to code everything for the
CF编写所有内容,那么我会手动将生成的DLL复制到WinForms项目中?
您只需添加类lib程序集(dll)作为参考,并将其用作

正常。

换句话说,如何强制一个类库总是为
CF编译?

将代码放在智能设备项目中编译。该项目将设置为与CF编译的



-

Tim Wilson

..NET Compact Framework MVP

" Robert W." <滚装***** @ discussions.microsoft.com>在消息中写道

news:86 ********************************** @ microsof t.com ...蒂姆,

感谢您的回复。我认为你已经敲了敲头,因为所谓的幽灵问题。似乎正是我现在所经历的
体验。它们是可怕的!

关于你的后一个想法,如果我只是为
CF编写所有内容,那么我会手动将生成的DLL复制到WinForms项目中吗?换句话说,如何强制一个类库总是为
CF编译?
-
Robert W.
温哥华,不列颠哥伦比亚省
www.mwtech.com

Tim Wilson写道:
CF then I would manually copy the resultant DLL into the WinForms project? You would just add the class lib assembly (dll) as a reference and use it as
normal.
Put another way, how do I force a class library to always compile for the CF?
Place the code to compile in a smart device project. The project would be
set up to compile against the CF.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.com... Tim,

Thank you for your response. I think you''ve hit the nail on the head
because so-called "phantom issues" seem to be exactly what I''m experiencing now. They''re scary!

With regard to your latter idea, if I were just to code everything for the
CF then I would manually copy the resultant DLL into the WinForms project?
Put another way, how do I force a class library to always compile for the CF?
--
Robert W.
Vancouver, BC
www.mwtech.com

"Tim Wilson" wrote:
有一个问题(至少我将其分类)如果你有两个
项目,在同一个解决方案中,链接到同一个文件,然后
当该文件打开时,加载到解决方案中的最后一个项目
将优先于其他项目,并且此
项目的条件常量将被尊重以及智能感知显示信息
基于上次加载的项目的引用。简而言之,如果您在同一解决方案中的项目之间共享
文件,并且一个项目的目标是
完整框架,而另一个项目的目标是紧凑框架,那么
可能会出现问题,在这种情况下似乎就是这种情况。我所知道的唯一
解决方法是将每个项目放入自己的解决方案中。这是
并不好,但它比处理共享
文件的幻像问题更好。你的情况中的另一个选择是使用紧凑框架代码和编译你的类库,只使用完整框架中也存在的紧凑框架
类,类库将是
可在桌面上使用,因为它可以重新定位。

- Tim Wilson
.. NET Compact Framework MVP

Robert W. " <滚装***** @ discussions.microsoft.com>在消息中写道
新闻:ED ********************************** @ microsof t.com。 ..
There is an issue (at least I classify it as such) where if you have two
projects, in the same solution, that are linking to the same file, then when that file is open the last project that was loaded into the solution will take precedence over the others and the conditional constants for this
project will be honored as well as intellisense showing information based on the references of the last project loaded. In short, if you''re sharing files between projects in the same solution, and one project is targeting the full framework while the other is targeting the compact framework then you may see issues, as it appears is the case in this situation. The only workaround that I''m aware of is to place each project into its own solution. It''s not nice but it''s better than dealing with the phantom issues of shared files. The other option in your situation is to code, and compile, your class
library against the compact framework, using only compact framework classes that also exist in the full framework, and the class library will be usable on the desktop as it is retargetable.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:ED**********************************@microsof t.com...
我正在构建一个解决方案,其中包含1个桌面组件和1个
I''m building a solution that has 1 component for the Desktop and 1


组件

,用于Pocket PC。 (虽然这不是一个移动问题)。

我有一个将在两个平台上共享的数据库。所以我已经采用了让两个项目共享同一组
文件的方法。
for the Pocket PC. (Though this isn''t a mobile question).

I have a data library that will be shared on both platforms. So I''ve
adopted the approach of having two projects share the same set of files.
我的情况,我有两个同样命名的项目:
DataObjects
DataObjectsCF

前者用于桌面应用程序,后者用于Compact
my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact


Framework。


Framework.


在这两个项目共享的许多类中,我有一些如下所示的条件编译语句:
#if(CF)

其中''CF''用于表示仅用于Pocket PC的代码和

Throughout the many classes shared by these two projects I have some
conditional compilation statements that look like this:
#if (CF)

where ''CF'' is used to denote code only for the Pocket PC and



相反''!CF' '仅用于桌面的代码。

我打开了DataObjectsCF的属性并添加了条件
编译常量''CF''。奇怪的是,这对待所有
文件看着通过DataObjects就好像我在调试掌上电脑应用程序一样,当我正在使用桌面应用程序时显示


为什么会这样?

-
Robert W.
BC省温哥华
www.mwtech.com




这篇关于2个项目共享1组文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆