2011-07-05 51 views
1

我试图用NHibernate.dll生成一个moles程序集使用下载的可执行文件,但生成的代码带有一些生成错误我不知道如何解决(如果甚至可能的话)。无法生成NHibernate.Moles.dll - 在生成的代码中生成错误

这是我做的:

  1. 复制NHibernate.dll和Iesi.Collections.dll到一个新的目录。
  2. 人大常委会在该目录中,运行../pathtomoles/moles.exe NHibernate.dll

痣然后输出如下:

 
Microsoft Moles v0.94.51023.0 - http://research.microsoft.com/moles - .NET v4.0. 
30319 
Copyright (c) Microsoft Corporation 2007-2010. All rights reserved. 

00:00:00.00> moles 
    Moles : info : metadata : loading D:\ ... \NHibernate.dll 
    Moles : info : compilation : output assembly name: NHibernate.Moles 
    Moles : info : code : found 2018 types 
    Moles : info : code : visibility: exported or assembly(NHibernate.Moles) 
    00:00:01.87> code generation 
    Moles : info : code : generating code at D:\ ... \obj\moles\nh\m.g.cs 
    00:00:02.05> stubs generation 
     Moles : info : code : generated 1361 stub types 
    00:00:05.68> moles generation 
     Moles : info : code : generated 1552 mole types 
    00:00:24.13> compiling

和构建失败,出现以下错误:

error CS0122: 'Remotion.Data.Linq.Clauses.ResultOperatorBase' 
is inaccessible due to its protection level 

error CS0703: Inconsistent accessibility: constraint type 
'Remotion.Data.Linq.Clauses.ResultOperatorBase' is less accessible than 
'NHibernate.Linq.Visitors.ResultOperatorProcessors.Moles.MResultOperatorProcessor'

我已经打开了项目来查看我是否可以自己修复错误,但结果是Moles在一个单独的代码文件中生成了所有的东西,这是巨大的(构建错误发生在第333100行和第333102行...),所以Visual Studio或多或少地打开了。

有无论如何解决这一代错误?我已经看过了moles.exe的选项,但我没有得到太多。

是否有其他人已经生成NHibernate.Moles.dll?如果是这样,我在哪里可以找到它?由于.意味着谷歌搜索“的任何单词分隔符”,它并没有给我太多...


完整的构建输出,以供参考:

--- Output 
Build started 2011-07-05 10:19:03. 
Project "D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies 
\NHibernate Moles\obj\moles\nh\m.g.csproj" on node 1 (default targets). 
PrepareForBuild: 
    Creating directory "b\". 
    Creating directory "o\". 
GenerateTargetFrameworkMonikerAttribute: 
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output fil 
es are up-to-date with respect to the input files. 
CoreCompile: 
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe /noconfig /unsafe+ /no 
warn:1587,1591,1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /doc:b\NHibernat 
e.Moles.xml /define:TRACE /reference:ic="D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\ 
Microsoft Moles\PublicAssemblies\NHibernate Moles\Iesi.Collections.dll" /referen 
ce:"C:\Program Files (x86)\Common Files\Microsoft Shared\ExtendedReflection\0.94 
.51023.0\bin\Microsoft.ExtendedReflection.dll" /reference:mmf="C:\Program Files 
(x86)\Microsoft Moles\PublicAssemblies\Microsoft.Moles.Framework.dll" /reference 
:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\ 
v4.0\mscorlib.dll" /reference:nh="D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microso 
ft Moles\PublicAssemblies\NHibernate Moles\NHibernate.dll" /reference:"C:\Progra 
m Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System 
.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Fra 
mework\.NETFramework\v4.0\System.Data.dll" /reference:"C:\Program Files (x86)\Re 
ference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" /reference 
:ssm="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramew 
ork\v4.0\System.ServiceModel.dll" /reference:st="C:\Program Files (x86)\Referenc 
e Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Transactions.dll" /re 
ference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFra 
mework\v4.0\System.Xml.dll" /debug:pdbonly /keyfile:m.g.snk /optimize+ /out:o\NH 
ibernate.Moles.dll /target:library m.g.cs "C:\Users\Tomas\AppData\Local\Temp\.NE 
TFramework,Version=v4.0.AssemblyAttributes.cs" 
m.g.cs(333102,50): error CS0122: 'Remotion.Data.Linq.Clauses.ResultOperatorBase' 
is inaccessible due to its protection level [D:\Projects\NCVIB-GIT\NCVIB\src\Ve 
ndor\Microsoft Moles\PublicAssemblies\NHibernate Moles\obj\moles\nh\m.g.csproj] 
m.g.cs(333100,26): error CS0703: Inconsistent accessibility: constraint type 'Re 
motion.Data.Linq.Clauses.ResultOperatorBase' is less accessible than 'NHibernate 
.Linq.Visitors.ResultOperatorProcessors.Moles.MResultOperatorProcessor' [D:\P 
rojects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies\NHibernate M 
oles\obj\moles\nh\m.g.csproj] 
Done Building Project "D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\Pu 
blicAssemblies\NHibernate Moles\obj\moles\nh\m.g.csproj" (default targets) -- FA 
ILED. 

Build FAILED. 

"D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies\NHibern 
ate Moles\obj\moles\nh\m.g.csproj" (default target) (1) -> 
(CoreCompile target) -> 
    m.g.cs(333102,50): error CS0122: 'Remotion.Data.Linq.Clauses.ResultOperatorBas 
e' is inaccessible due to its protection level [D:\Projects\NCVIB-GIT\NCVIB\src\ 
Vendor\Microsoft Moles\PublicAssemblies\NHibernate Moles\obj\moles\nh\m.g.csproj 
] 
    m.g.cs(333100,26): error CS0703: Inconsistent accessibility: constraint type ' 
Remotion.Data.Linq.Clauses.ResultOperatorBase' is less accessible than 'NHiberna 
te.Linq.Visitors.ResultOperatorProcessors.Moles.MResultOperatorProcessor' [D: 
\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies\NHibernate 
Moles\obj\moles\nh\m.g.csproj] 

    0 Warning(s) 
    2 Error(s) 

Time Elapsed 00:00:03.24 




--- Environment 

    Moles : warning : compilation : project compilation failed with exit code 1 
    Moles : warning : compilation : compilation failed, retrying without Code Co 
ntracts 
--- Output 
Build started 2011-07-05 10:19:06. 
Project "D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies 
\NHibernate Moles\obj\moles\nh\m.g.csproj" on node 1 (default targets). 
GenerateTargetFrameworkMonikerAttribute: 
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output fil 
es are up-to-date with respect to the input files. 
CoreCompile: 
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe /noconfig /unsafe+ /no 
warn:1587,1591,1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /doc:b\NHibernat 
e.Moles.xml /define:TRACE /reference:ic="D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\ 
Microsoft Moles\PublicAssemblies\NHibernate Moles\Iesi.Collections.dll" /referen 
ce:"C:\Program Files (x86)\Common Files\Microsoft Shared\ExtendedReflection\0.94 
.51023.0\bin\Microsoft.ExtendedReflection.dll" /reference:mmf="C:\Program Files 
(x86)\Microsoft Moles\PublicAssemblies\Microsoft.Moles.Framework.dll" /reference 
:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\ 
v4.0\mscorlib.dll" /reference:nh="D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microso 
ft Moles\PublicAssemblies\NHibernate Moles\NHibernate.dll" /reference:"C:\Progra 
m Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System 
.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Fra 
mework\.NETFramework\v4.0\System.Data.dll" /reference:"C:\Program Files (x86)\Re 
ference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" /reference 
:ssm="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramew 
ork\v4.0\System.ServiceModel.dll" /reference:st="C:\Program Files (x86)\Referenc 
e Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Transactions.dll" /re 
ference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFra 
mework\v4.0\System.Xml.dll" /debug:pdbonly /keyfile:m.g.snk /optimize+ /out:o\NH 
ibernate.Moles.dll /target:library m.g.cs "C:\Users\Tomas\AppData\Local\Temp\.NE 
TFramework,Version=v4.0.AssemblyAttributes.cs" 
m.g.cs(333102,50): error CS0122: 'Remotion.Data.Linq.Clauses.ResultOperatorBase' 
is inaccessible due to its protection level [D:\Projects\NCVIB-GIT\NCVIB\src\Ve 
ndor\Microsoft Moles\PublicAssemblies\NHibernate Moles\obj\moles\nh\m.g.csproj] 
m.g.cs(333100,26): error CS0703: Inconsistent accessibility: constraint type 'Re 
motion.Data.Linq.Clauses.ResultOperatorBase' is less accessible than 'NHibernate 
.Linq.Visitors.ResultOperatorProcessors.Moles.MResultOperatorProcessor' [D:\P 
rojects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies\NHibernate M 
oles\obj\moles\nh\m.g.csproj] 
Done Building Project "D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\Pu 
blicAssemblies\NHibernate Moles\obj\moles\nh\m.g.csproj" (default targets) -- FA 
ILED. 

Build FAILED. 

"D:\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies\NHibern 
ate Moles\obj\moles\nh\m.g.csproj" (default target) (1) -> 
(CoreCompile target) -> 
    m.g.cs(333102,50): error CS0122: 'Remotion.Data.Linq.Clauses.ResultOperatorBas 
e' is inaccessible due to its protection level [D:\Projects\NCVIB-GIT\NCVIB\src\ 
Vendor\Microsoft Moles\PublicAssemblies\NHibernate Moles\obj\moles\nh\m.g.csproj 
] 
    m.g.cs(333100,26): error CS0703: Inconsistent accessibility: constraint type ' 
Remotion.Data.Linq.Clauses.ResultOperatorBase' is less accessible than 'NHiberna 
te.Linq.Visitors.ResultOperatorProcessors.Moles.MResultOperatorProcessor' [D: 
\Projects\NCVIB-GIT\NCVIB\src\Vendor\Microsoft Moles\PublicAssemblies\NHibernate 
Moles\obj\moles\nh\m.g.csproj] 

    0 Warning(s) 
    2 Error(s) 

Time Elapsed 00:00:02.76

回答

2

如果我生成所有类型我确实得到了一个错误,但是你可以在nhibernate中进行子类型的选择,这有可能产生痣。

在我vs.net项目的NHibernate.moles文件:

<Moles xmlns="http://schemas.microsoft.com/moles/2010/"> 
    <Assembly Name="NHibernate" /> 
    <StubGeneration > 
    <Types > 
     <Clear /> 
     <Add TypeName ="Session"/> 
    </Types> 
    </StubGeneration> 
    <MoleGeneration > 
    <Types > 
     <Clear /> 
     <Add TypeName ="Session"/> 
    </Types> 
    </MoleGeneration> 
</Moles> 

好吧我使用.moles文件中的参数:

"C:\Program Files\Microsoft Moles\bin\moles.exe" /mfo /nologo /tfv:v4.0 /r:"<full path>\NHibernate.dll;<full path>\Iesi.Collections.dll" "NHibernate.moles" 

我不知道,如果你需要如果你对这些类型没有做任何事情,请包括Iesi.Collections。

+0

我试着添加一个名为NHibernate.moles的文件到NHibernate dll的目录下,运行'moles.exe NHibernate.moles',但没有成功。鼹鼠似乎没有找到任何东西存根,所以它只是退出而没有做任何事情。 'moles.exe/mfo NHibernate.dll'抱怨说没有组件被发现鼹鼠。 –

+0

我更新了摩尔参数。我测试的NHibernate版本是3.2。 – Peter

+0

你现在正式成为我的英雄=) –