有人可以在这里发布一个如何在Delphi中托管CLR的例子吗?我在这里读过类似的问题,但我不能使用JCL,因为我想在Delphi 5中托管它.谢谢.
编辑:这文章关于福克斯临托管CLR看起来很有希望,但我不知道如何从德尔福访问clrhost.dll.
编辑2:我放弃了Delphi 5的要求.现在我正在尝试使用Delphi 7进行JCL.但是我再也找不到任何示例.这就是我现在所拥有的:
我的C#程序集:
namespace DelphiNET
{
public class NETAdder
{
public int Add3(int left)
{
return left + 3;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我把它编译成了DelphiNET.dll.
现在我想使用Delphi的这个程序集:
uses JclDotNet, mscorlib_TLB;
procedure TForm1.Button1Click(Sender: TObject);
var
clr: TJclClrHost;
ads: TJclClrAppDomainSetup;
ad: TJclClrAppDomain;
ass: TJclClrAssembly;
obj: _ObjectHandle;
ov: OleVariant;
begin
clr := TJclClrHost.Create();
clr.Start;
ads := clr.CreateDomainSetup;
ads.ApplicationBase := 'C:\Delhi.NET';
ads.ConfigurationFile := 'C:\Delhi.NET\my.config';
ad := clr.CreateAppDomain('myNET', ads);
obj := (ad as _AppDomain).CreateInstanceFrom('DelphiNET.dll', 'DelphiNET.NETAdder');
ov …Run Code Online (Sandbox Code Playgroud) Grid.SharedSizeGroupSilverlight 4中没有.这个问题的解决方法是什么?
例如:我有一个DataTemplate为ListBox.ItemTemplate具有两列组成的网格的,我想具有用于两列和第一列需要具有自动宽度相同的宽度.
我有一个简单的vbscript来检索Windows版本:
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colVersions = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For Each objVer in colVersions
ver = objVer.Version
Next
Run Code Online (Sandbox Code Playgroud)
有可能获得第一条记录,或者我必须遍历集合中的所有记录.我见过的所有例子都是For Each建筑.我尝试时收到预期的语句结束错误:
ver = colVersions[0].Version
Run Code Online (Sandbox Code Playgroud)
看起来返回值ExecQuery不是一个合适的集合.
我安装了最新的PhoneGap版本(3.3),打包了我的移动服务HTML应用程序并点击了已知的授权问题:
仅从http://和https:// URL支持登录.请将您的页面托管在Web服务器中
我已经在互联网上搜索了这个问题(http://social.msdn.microsoft.com/Forums/windowsazure/en-US/a2386093-73cd-44fb-a418-4fa83a36c800/phonegap-apps-using-the-new-html -client-for-azure-mobile-services-not-working?forum = azuremobile)但该解决方案对我不起作用.该项目由phonegap参考创建,<script type="text/javascript" src="phonegap.js"></script>但即使我将其更改为<script type="text/javascript" src="cordova.js"></script>它也无效.
这个问题有什么解决方案吗?
我的源代码:
<html>
<head>
<meta charset="utf-8" />
<title>Report</title>
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
<script type="text/javascript" src="cordova.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/mobileservices/MobileServices.Web-1.1.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="myscript.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)
myscript.js
var app = {
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
var client = new WindowsAzure.MobileServiceClient(
"https://myapp.azure-mobile.net/", "XXX");
client.login("google").done(....
},
};
$(document).ready(function documentReady() {
app.initialize();
});
Run Code Online (Sandbox Code Playgroud)
显然,PhoneGap …
我想创建一个可以从非托管代码(Delphi 5)访问的.NET程序集.
我找到了Unmanaged Exports并按照那里的步骤进行了操作但是我甚至无法成功编译基本示例:
using RGiesecke.DllExport;
namespace DelphiNET
{
public class Class1
{
[DllExport("add")]
public static int Add(int left, int right)
{
return left + right;
}
}
}
Run Code Online (Sandbox Code Playgroud)
DelphiNET.csproj 项目文件:
...
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="DllExport\DllExportAttribute.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="DllExport\RGiesecke.DllExport.targets" />
...
Run Code Online (Sandbox Code Playgroud)
这是错误:
------ Build started: Project: DelphiNET, Configuration: Release Any CPU ------
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:TRACE /debug:pdbonly /filealign:512 /optimize+ /out:obj\Release\DelphiNET.dll /target:library Class1.cs DllExport\DllExportAttribute.cs Properties\AssemblyInfo.cs
Compile complete -- …Run Code Online (Sandbox Code Playgroud) 从Microsoft的文档中,两个Equals方法基本相同.但我偶然发现了一些非常奇怪的事情.在我的Silverlight项目中,我有两个同一类的实例覆盖了Equals.如果我要inst1.Equals(INST2)或inst2.Equals(INST1)我总是得到真正的结果.但是Object.Equals(inst1,inst2)返回false.这怎么可能?
有任何想法吗?
谢谢,Rocko
我想使用Jon Skeet的SmartEnumerable来循环,Regex.Matches但它不起作用.
foreach (var entry in Regex.Matches("one :two", @"(?<!\w):(\w+)").AsSmartEnumerable())
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下为什么吗?并提出一个解决方案,使其工作.谢谢.
错误是:
'System.Text.RegularExpressions.MatchCollection' does not contain a definition
for 'AsSmartEnumerable' and no extension method 'AsSmartEnumerable' accepting
a first argument of type 'System.Text.RegularExpressions.MatchCollection' could
be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
delphi ×2
android ×1
clr ×1
cordova ×1
dll ×1
grid ×1
host ×1
html ×1
ienumerable ×1
iequatable ×1
javascript ×1
regex ×1
silverlight ×1
unmanaged ×1
vbscript ×1
windows ×1
wmi ×1