具有许多表的数据库上的 VS2008 T4 Subsonic 错误 System.Runtime.Remoting.RemotingException
在一项咨询任务中,他们使用 Subsonic 3.x(最新),它使用 T4 代码模板引擎(而不是像 2.x 那样的 CodeSmith)。
当我们在拥有约 1000 个表的 DBMS 上运行它时,我们会遇到错误生成Structs.cs 文件。 T4/Subsonic 在较小的 DB 上生成良好......
运行转换代码时抛出异常。该过程无法继续。引发以下异常:
System.Runtime.Remoting.RemotingException:对象 '/f9ce56f8_409c_4465_b81c_5272c8d764dc/dbet1oh1u2djvp2ildubn9nb_25.rem' 已断开连接或服务器上不存在。 在 Microsoft.VisualStudio.TextTemplate.TransformationRunner.get_Errors() 在 Microsoft.VisualStudio.TextTemplate.Engine.CompileAndRunCode(字符串 生成器代码、ITextTemplateEngineHost 主机、 TemplateProcessingSession 会话) C:\Users\BlahBlahUserName\Documents\Visual Studio 2008\EdsTry\EdSub\ActiveRecord\Structs.tt
这导致了两个问题
有没有人见过这个并知道 T4 爆炸时的任何解决方法 大文件?
一旦我解决了这个问题,我可以修改亚音速以使其产生更少的声音吗? 文件(例如 1,000 个类文件而不是 1 个大型类文件)
如果我们在主项目中包含 Subsonic 生成工具,Vstudio 会被它生成的大型类文件阻塞,因此我们在单独的项目中执行此操作并引用生成的 DLL,但肯定必须有一种从亚音速与 1 生成数百个类文件的方法 文件中包含数百个类。
At a consulting assignment they are using Subsonic 3.x (latest) which uses the T4 Code Templating Engine (rather than CodeSmith like 2.x did)
When we run it on our DBMS that has ~ 1 thousand tables we run into an error generating the Structs.cs file. T4/Subsonic generates fine on smaller DBs....
An Exception was thrown while running the transformation code. The process cannot continue. The following Exception was thrown:
System.Runtime.Remoting.RemotingException: Object
'/f9ce56f8_409c_4465_b81c_5272c8d764dc/dbet1oh1u2djvp2ildubn9nb_25.rem'
has been disconnected or does not exist at the server.
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.get_Errors()
at Microsoft.VisualStudio.TextTemplating.Engine.CompileAndRunCode(String
generatorCode, ITextTemplatingEngineHost host,
TemplateProcessingSession session)
C:\Users\BlahBlahUserName\Documents\Visual Studio
2008\EdsTry\EdSub\ActiveRecord\Structs.tt
This leads to two questions
has anyone seen this and know any workarounds when T4 blows up on
large files?And once I solve that can I modify subsonic so it generates less
files (say 1,000 class files rather than 1 large class file)
Vstudio chokes on the large class files it generates if we include the Subsonic generation stiuff in our main project so we do it in separate project and reference the resulting DLL but surely there must be a way to generate several hundred class files from subsonic vs. 1
file with several hundred classes in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的问题是数据库连接超时,您最好的办法可能是使用本地数据库服务器而不是远程数据库服务器,这样您就不会一直等待数据。
另外,如果您查看 TT 文件,您会注意到它获取所有表的列表,循环遍历这些表,然后循环遍历字段,TT 文件是一个从模板创建类的文件,而不是创建文件并保存他们在某个地方。
但是如果你的数据库太大,有超过1000个表,我认为你最好从数据库设计开始,也许将表分成一组数据库,并有多个dal,即产品数据库,人员数据库,等等这样你就可以让它变小
如果这有意义的话,仍然可以使用它们
your problem is your DB connection timeout, your best best would prob be to work of a local DB server rather than remote so your not waiting for the data alll the time.
also if you look at the TT file you will notice that it gets a list of all tables, loops through them tables and then loops through the fields, the TT file is a file to create a class from template, not to create files and save them somewhere.
but if your database is so massive that you have more than 1000 tables i think you would be better starting at DB design, and maybe splitting the tables into a group of database, and having multiple dals, I.E a product db, a people DB, etc this way you will keep it small
and will still be able to use them all if this makes sense
我也遇到了同样的问题,发现这个错误是由于连接超时引起的。
这就是我连接到数据库以检索所有实体/视图/过程/等的方式:
关键时刻是设置这两个参数:
设置这些参数后,我的生成器运行良好。
希望它对你有用。
I had the same problem and found that this error caused because of connection timeout.
This is how I connect to a database for retrieving of all entities/views/procedures/etc.:
The key moment is to set these two arguments:
After setting these my generator works well.
Hope it will work for you.
如果您的软件不需要全部 1000 个表,那么您可以将黑名单“ExcludeTables”转换为白名单“IncludeTables”,并在 *.tt 文件中查找/替换所有“!ExcludeTables”为“IncludeTables”。另外,我更改了 SQLServer.ttinclude 中的 LoadTables() 以在执行任何其他调用之前检查我的白名单并添加表:
我对 SQLServer.ttinclude 中的存储过程的 GetSPs() 执行了相同的操作:
现在所有 *.tt 都执行没有远程处理异常。
If your software does not require all 1000 tables, then you could turn the black list "ExcludeTables" into a whitelist "IncludeTables" and find/replace all "!ExcludeTables" with "IncludeTables" in the *.tt files. Also, I changed the LoadTables() in SQLServer.ttinclude to check my whitelist before it does any other calls and adds the table:
I did the same for the Stored Procedures' GetSPs() in SQLServer.ttinclude:
Now all *.tt execute without the Remoting Exception.