我在枚举中使用Description属性为枚举字段提供用户友好名称.例如
public enum InstallationType
{
[Description("Forward of Bulk Head")]
FORWARD = 0,
[Description("Rear of Bulk Head")]
REAR = 1,
[Description("Roof Mounted")]
ROOF = 2,
}
Run Code Online (Sandbox Code Playgroud)
使用一个很好的帮助方法很容易访问它:
public static string GetDescriptionFromEnumValue(Enum value)
{
DescriptionAttribute attribute = value.GetType()
.GetField(value.ToString())
.GetCustomAttributes(typeof(DescriptionAttribute), false)
.SingleOrDefault() as DescriptionAttribute;
return attribute == null ? value.ToString() : attribute.Description;
}
Run Code Online (Sandbox Code Playgroud)
我需要将其转换为可移植的类库,但它似乎无法访问System.ComponentModel库.当我尝试添加一个崇敬的VS时告诉我,我已经引用了所有内容.
谢谢
好的我知道这已经被弃用了,而且bde比Moses旧,但是我们还有一些遗留的应用程序还没有使用bde进行迁移.
有没有人成功安装bde与完全配置为Windows 7(32和64位)的interbase sql链接?
我发现了许多不同的帖子和可执行文件,但没有结论.
谢谢
我收到此错误 "无法从程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Runtime.CompilerServices.ExtensionAttribute'."
每当我在我的网站的bin目录中包含quartz.net的dll并在代码中引用它.我确信它与错误的.net框架有关.
我的asp.net站点正在使用目标框架4.0我正在使用.net 4 quartz.net文件
我的IIS应用程序池(经典的.net池)设置为运行.net 4.0 frework.
我不知道从哪里开始,但我确定知道的是删除Quartz并且我再次看起来很好(减去调度)
我正在忙着编写一个为宿主应用程序提供多种功能的DLL.此应用程序动态调用dll,在每次函数调用后加载并释放它.
我无法控制主机应用程序.我只能在dll中工作.有没有办法可以将某些变量保存在内存中,以便我可以在每个函数中重用它们?当主机应用程序卸载dll时,显然会清除全局变量.将dll保存到文件听起来非常混乱!
任何人都可以建议一种分配变量的方法吗?
谢谢
说我有以下课程:
class Animal
{
public long Id { get; set; }
public string Name { get; set; }
}
class Dog:Animal
{
public void sniffBum()
{
Console.WriteLine("sniff sniff sniff");
}
}
Run Code Online (Sandbox Code Playgroud)
如果我有一个实例Animal,我该如何将其转换为Dog?像这样的东西:
Animal a = new Animal();
if ( some logic to determine that this animal is a dog )
{
Dog d = (Dog)a;
d.sniffBum();
}
Run Code Online (Sandbox Code Playgroud)
基本上我不能使用接口.我将永远有一个Animal像我这样的数据库.Dog没有任何参数Animal,只有新方法.
我可以创建一个新Dog对象,并传递值,(或者有一个带有类型的构造函数Animal),但这看起来很麻烦.
听起来有点愚蠢和琐碎,具有讽刺意味的是,我确信通过输入这个问题,我实际上已经失去了比我可能获得的更多的时间:)
但我只是想知道其他视觉工作室的人是否已经解决了这个问题
当写出很多lambda函数时(特别是在做一个流畅的配置时),输入一个lambda感觉非常低效,等号字符在键盘的顶部数字行上,并且大于号就是他所有的方式通过空格键向下,它需要在似乎时间使用移位.
只是感觉很麻烦
只是想知道是否有人知道如何构建宏或快捷方式.我更愿意双击一个键或类似的东西.它可以更快地打字
(注意:我正在使用VS 2010和2012)
有人可以告诉我我做错了什么.我正在尝试设置qurtz,以便在启动时它将读取xml配置文件.在文件中有一个激活我的HelloEmail_Job.cs类的作业(它被正确创建,使用execute方法中的逻辑扩展IJob).xml还有一个cron触发器,用于每分钟触发的作业(纯粹用于测试)
但一切都没有错误地启动,但工作永远不会发生.我确信我配置错误
我有一个处理我的调度程序生成的单例,调度程序在我的应用程序启动时启动(在global.asax文件中)
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "RemoteServer";
////// set thread pool info
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "5";
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";
properties["quartz.dataSource.default.connectionString"] = "Data Source=CRAIG-PC\\SQLEXPRESS;Initial Catalog=MCWdb;User ID=sa;Password=mastercrud;";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
// job initialization plugin handles our xml reading, without it defaults are used
properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz";
properties["quartz.plugin.xml.fileNames"] = "~/quartz_jobs.xml";
ISchedulerFactory sf = new StdSchedulerFactory(properties);
_sched = sf.GetScheduler(); …Run Code Online (Sandbox Code Playgroud) 我似乎对这篇文章有类似的问题,不同之处在于我是2支球队的开发者.我的团队生成特殊的分发配置文件(团队A)我也是这个团队的创造者.当我为团队B创建一个时,我遇到了一个问题,我的xcode说"找不到有效的签名身份".
我已经尝试删除,重新导入分发证书etcetc.weirdly我可以创建一个开发条款,但不是分发版.B队在他们的系统中创建了我作为管理员,但没有运气.我很难过.
我们考虑撤销他的发行证书并重新创建它,这会有效吗?注意:他在应用程序商店中确实有其他应用程序.
grrrrrr
注意:我需要它是一个特殊的ditribution,以便我可以把它交给testFlight
我还要补充一点,我有B队的完整发行证书(使用私钥).他把它出口给我.也没有帮助
我有一个webforms应用程序,其中有一些Web Api控制器用于集成.两个工作正常.但今天我想添加另一个控制器.
应该很简单,我添加一个新的Web Api控制器,向它添加一些代码,并且:
namespace MyApp.Web.App_Code
{
public class AuthExportController : ApiController
{
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我在这个网址上调用它时:
http://localhost:30978/MyApp/api/AuthExport
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>Multiple types were found that match the controller named
'AuthExport'. This can happen if the route that services this request
('api/{controller}/{id}') found multiple controllers defined with the same name but
differing namespaces, which is not supported. The request for 'AuthExport' has found
the following matching …Run Code Online (Sandbox Code Playgroud) 我刚刚在 winforms 应用程序中发现的东西
我的应用程序对 Web Api 服务进行 http 调用,如下所示
HttpClient _client = new HttpClient();
_client.Timeout = new TimeSpan(0, 3, 0);
_client.BaseAddress = new Uri("http://Myserver/MyApp");
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = _client.PostAsJsonAsync("api/Addin", newObject).Result;
Run Code Online (Sandbox Code Playgroud)
没什么特别的,但是一旦你通过 nuget 安装 Newtonsoft.Json (V6.0.3)
突然我在 HttpResponseMessage 代码行上收到 stackOverflow 错误。删除Newtonsoft,问题就解决了。
问题是我要使用该库在表单中的其他位置序列化/反序列化数据
我的解决方法是使用不同的库,我只是使用 System.Runtime.Serialization.Json;但这仍然很奇怪,不是吗?
我还应该补充一点,这是 dotnet v4.0(不是 4.5),我的应用程序是一个在 MsWord 中作为附加组件运行的 VSTO COM 对象
我怀疑 Newtonsoft 可能存在错误