我正在尝试评估Excel DNA,以便在我的一个excel加载项中使用它.我使用C#函数(.NET 4.0)并希望从Excel调用这些函数.我感兴趣的原因是,我的插件的用户是非管理员,因此如果我能找到一个解决方案,不要在我的.NET dll上做一个regasm,让我的插件工作,那将是一个突破.
我理解,如果它就像一个工作表函数(具有简单的返回类型和参数),如:private string Add (int a, double b)
我可以使用excel dna轻松地展开它们.另外,据我所知,我也可以使用VBA中的Application.Run调用这些简单的函数.
但是,如果我有一个涉及API的复杂类型并希望从VBA使用它,那么我是否需要重新组合该程序集和类型?示例如下:
private MyType AddLogic (myType1 A, myType2 B)
Run Code Online (Sandbox Code Playgroud)
或者Excel Excel中是否有任何方法,我还可以在VBA中使用这类函数而不需要任何regasm或regsvr32?
谢谢Mani
需要任何帮助,想法来找出这个问题.
我们正在开发一个应用程序,该应用程序调用SAP以使用ERPConnect发布一些数据.我们在WCF服务中的一个Entity Framework调用中遇到以下问题.我们使用的是.NET4.0,Win 2008 Server.
活动中包含以下信息:
exception in getting ****getrebateproposal**-****Common Language Runtime detected an invalid program.****** at System.Data.Entity.DynamicProxies.RebateProposal_E1004D9B0153012E0A7A09FC9B574872909349EC992253740AB3C066FC63CF4D.set_Id(Decimal )
at lambda_method(Closure , Shaper )
at System.Data.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
at lambda_method(Closure , Shaper )
at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at CommercialTermsRepository.GetRebateProposalsAmountToPay(String rebateAgreement) in D:\Projects\TFS\CIT V2\DataModel\BusinessObjects\CommercialTermsRepository.cs:line 794
at SAPInterface.RebateProposalService.SetZv41Data(List`1 uploadRebates) in D:\Projects\TFS\CIT V2\Server\UserService\RebateProposalService.svc.cs:line 187
Run Code Online (Sandbox Code Playgroud) 可能重复:
.NET:ArrayList vs List
你好,
我在网上搜索并发现我的冲突答案,到目前为止还不清楚,哪一个更快List<T> or ArrayList<T>,是什么原因?
我猜测List<T>应该更快但不确定,因为在这种特定情况下甚至ArrayList<T>也被标记为通用类型.
非常感谢,Mani
我有一个有两个属性和两个方法的类.比如下面的例子.(请忽略数据类型或返回类型,这只是一个典型的场景)
// The methods could be invoked by multiple threads
public class Stock
{
private static int FaceValue {get; set;}
private static int Percent (get; set;}
// method that updates the two properties
Public void UpdateStock()
{
FaceValue += 1;
Percent = FaceValue * 100;
}
// method that reads the two properties
public int[] GetStockQuote()
{
return new int[] { FaceValue, Percent};
}
}
Run Code Online (Sandbox Code Playgroud)
我需要确保这个类是线程安全的.我可以在这两种方法中使用lock(obj)作为一种技术来使其成为线程安全但是考虑到以下因素,最好的技术是使其成为线程安全的:
只读取/更新了两个属性.因此,不确定锁定方法内是否是一种好方法.
如果我只是使属性线程安全而不是方法或类是否足够?
另外,有没有办法使整个类线程安全而不是单独的方法或属性?.Net 4.0的任何推荐的锁定技术?
只是想知道我是否正在考虑这个权利,或者考虑到这些,我可能会使它复杂化.非常感谢提前帮助我明确这一点.
玛尼
这是一个简单的问题,但我想了解内存中会发生什么.
我知道将值类型转换为引用类型是装箱.
int I = 10;
object obj = I; // boxing - I is moved from stack to heap
Run Code Online (Sandbox Code Playgroud)
1. int数组的内容:
int[] arrInt = new int[1];
arrInt[0] = 10;
int I = arrInt[0];
Run Code Online (Sandbox Code Playgroud)
在这里,我知道arrInt在堆栈中(带有地址到堆)并且指向堆存储'10'的堆.
在这种情况下,10'盒装'并存储在堆中?或者它作为未装箱的值类型存在?所以,当我重新访问该项目时,int I = arrInt[0]会发生什么?
2. int通用列表的内容:
List<int> lstInt = new List<int>(){10};
int I = lstInt[0];
Run Code Online (Sandbox Code Playgroud)
在通用的情况下List<int>,在msdn文档中,它引用using generic collections avoids the overhead of boxing:" http://msdn.microsoft.com/en-us/library/vstudio/ms172194(v=vs.100).aspx "但我不明白,如果在泛型中List的情况下整数值是如何存储的?这是不是意味着它存在于未装箱状态?那么,在这种情况下,如果我访问int I = lstInt[0],在这种情况下会发生什么?
谢谢.