dim _cache As System.Web.Caching.Cache = _ System.Web.HttpContext.Current.Cache dim assemblyPath as string dim className as string _cache.Insert( "IDataProviderBase", _ System.Reflection.Assembly.LoadFrom(assemblyPath).GetType(className).GetConstructor(Type.EmptyTypes), _ New CacheDependency( assemblyPath ))
you need to Imports System.Reflection Imports System.Web.Caching"Assembly" is a little weird, frankly, I don't know the reason, not sure if "Assembly" is a keyword
string是有的,并且都付过值了。继续……
===>
VB.NET: GetConstructor(Type.EmptyTypes)
string assemblyPath; //dll文件物理路径
string className; //要加载的类名字cache.Insert( "IDataProviderBase", Assembly.LoadFrom( assemblyPath).GetType( className ).GetConstructor(new Type[0]), new CacheDependency( assemblyPath ) );
----------------------------------------
dim cache as new Cache()
cache System.Web.HttpContext.Current.Cachedim assemblyPath as string
dim className as stringcache.Insert( "IDataProviderBase", Assembly.LoadFrom( assemblyPath).GetType( className ).GetConstructor(new Type[0]), new CacheDependency( assemblyPath ) )
System.Web.HttpContext.Current.Cache
dim assemblyPath as string
dim className as string _cache.Insert( "IDataProviderBase", _
System.Reflection.Assembly.LoadFrom(assemblyPath).GetType(className).GetConstructor(Type.EmptyTypes), _
New CacheDependency( assemblyPath ))
能不能稍稍解释一下,为什么 C# 里面直接写就可以, VB.net 就必须写上 System.Reflection... 才行呢?还有像上面的 Cache, C# 里面可以直接写 Cache cache;
VB.net 里面就必须写:Dim _cache As System.Web.Caching.Cache大致点拨一下就可以了,谢谢!
Imports System.Reflection
Imports System.Web.Caching"Assembly" is a little weird, frankly, I don't know the reason, not sure if "Assembly" is a keyword
Imports System.Web.CachingDim _cache As Cache
.......错误是:error BC30561: “Cache”不明确,从命名空间或类型“System.Reflection, System.Web.Caching”导入。“文档”中对此错误的描述为:“<name1>”不明确,从命名空间或类型“<name2>”导入提供的名称不明确,从而与另一个名称冲突。Visual Basic 编译器没有任何冲突解决规则,您必须自己消除名称的歧义。纠正此错误:* 移除命名空间导入,消除名称歧义。
* 完全限定名称。
================================Assembly 那个提示就是:需要表达式。“文档”里面对这个错误的解释是:运算符(例如 + 或 =)要求一个表达式作为其右操作数,但在其右侧没有找到可识别的表达式。纠正此错误:* 提供一个有效的表达式作为运算符的右操作数。
像上面那样的写在参数里面的,错误就标在 GetConstructor 下面。