它在AssemblyInfo.cs中为C#项目说明可以用它指定版本信息 *
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Run Code Online (Sandbox Code Playgroud)
我改成了这个:
[assembly: AssemblyVersion("1.0.*.*")]
[assembly: AssemblyFileVersion("1.0.*.*")]
Run Code Online (Sandbox Code Playgroud)
这是我从编译器得到的错误:
error CS0647: Error emitting 'System.Reflection.AssemblyVersionAttribute' attribute -- 'The version specified '1.0.*.*' is invalid'
warning CS1607: Assembly generation -- The …
Run Code Online (Sandbox Code Playgroud) 将ASP.NET Web Helpers Library更新到今天显然已发布的2.0版后,会出现此错误.我错误地更新了,但是如果可能的话,现在想解决这个问题.
检测到的ASP.NET网页版本存在冲突:指定版本为"1.0.0.0",但bin中的版本为"2.0.0.0".要继续,请从应用程序的bin目录中删除文件,或删除web.config中的版本规范.
显然这是web.config中的问题:
<add key="webpages:Version" value="1.0.0.0" />
Run Code Online (Sandbox Code Playgroud)
有没有人甚至有关于这个ASP.NET Web Helpers Library包2.0的任何信息?我无法找到发行说明.Nuget网站上没什么.
使用EF4 CTP5 DbContext,相当于此
public void Refresh(Document instance)
{
_ctx.Refresh(RefreshMode.StoreWins, instance);
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过了,但它不会做同样的事情,更新实例
public void Refresh(Document instance)
{
_ctx.ChangeTracker.DetectChanges();
}
Run Code Online (Sandbox Code Playgroud)
?
根据这个http://docs.nuget.org/docs/start-here/using-the-package-manager-console,我应该看到PM提示和命令get-packages
应该工作.使用我的VS2010,程序包管理器控制台提示符说
PS E:\myprojectfolder
Run Code Online (Sandbox Code Playgroud)
并且没有任何命令工作 - 它发出错误说:
PS E:\project> get-package -ListAvailable
The term 'get-package' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is co
rrect and try again.
At line:1 char:12
+ get-package <<<< -ListAvailable
+ CategoryInfo : ObjectNotFound: (get-package:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
以下正则表达式
var patt1=/[0-9a-z]+$/i;
Run Code Online (Sandbox Code Playgroud)
提取字符串的文件扩展名,例如
filename-jpg
filename#gif
filename.png
Run Code Online (Sandbox Code Playgroud)
如果字符串确实是一个带有一个点作为分隔符的文件名,如何修改此正则表达式只返回一个扩展名?(显然文件名#gif不是常规文件名)
更新根据tvanofsson的评论我想澄清一下,当JS函数收到字符串时,字符串将包含一个没有空格的文件名,没有点和其他特殊字符(实际上它将被处理slug
).问题不在于解析文件名,而在于错误地解析slugs - 函数返回了"jpg"的扩展名,当它被赋予"filename-jpg"时,它应该真正返回null
或清空字符串,这是需要纠正的行为.
显然,可以在运行时动态地将DataAnnotation属性附加到对象属性,从而实现动态验证.
有人可以提供代码示例吗?
在ServiceStack 的示例中,我没有首先看到ASP.NET MVC网站的单个应用程序,然后将ServiceStack服务放在第二位.
我们来看一个非常简单的ASP.NET MVC Web应用程序,它通过Views呈现产品.它使用控制器,视图,模型和视图模型.
假设我们有一个模型Product
被持久存储到文档DB中.假设我们有一个viewmodel,ProductViewModel
它从Product
MVC Razor View/PartialView中映射并显示.
所以这是一个网络方面的东西..现在让我们假设我们想要添加一个服务返回产品到各种客户端,如Windows 8应用程序.
请求/响应类是否应该与我们已有的完全断开?我们ProductViewModel
可能已经包含了我们想要从服务中返回的所有内容.
既然我们已经有了Product
(模型类),我们就不能Product
在API命名空间中拥有另一个类.我们可以但是这会使事情变得不清楚,我想避免这种情况.
那么,我们应该在API命名空间中引入独立ProductRequest
类和ProductRequestResponse
(继承ProductViewModel)类吗?
像这样ProductRequestResponse : ProductViewModel
?
我所说的是,我们已经拥有Model和ViewModel类,并为SS服务构建Request和Response类,我们必须创建另外两个文件,主要是通过复制我们已有的类中的所有内容.这对我来说看起来并不干净,它可能会遵循关注点分离指南,但DRY也很重要,实际上不仅仅是分离所有内容(将所有内容分开导致代码重复).
我希望看到的是一个已经建立了Web应用程序的情况,它目前具有Models和ViewModel,并返回适当的视图以便在Web上显示,但是可以扩展为支持程序化客户端的全功能服务?就像AJAX客户端......以及我们已经拥有的东西.
另一件事:
你会看到有Movie
Request类和Movies
Request类(一个用于单个电影请求,另一个用于电影列表).因此,也有两个服务,MovieService
并且MoviesService
,一个交易与一个单一的电影,另一部分用于电影的流派的请求.
现在,虽然我喜欢SS服务方法而且我认为它是正确的,但我不喜欢这种分离只是因为请求的类型.如果我想要导演的电影怎么办?我是否会发明另一个具有Director
属性的请求类以及另一个服务(MoviesByDirector
)?
我认为样本应该面向一项服务.所有必须处理电影的东西都需要在一个屋檐下.如何通过ServiceStack实现这一目标?
public class ProductsService : Service
{
private readonly IDocumentSession _session;
private readonly ProductsHelperService _productsHelperService;
private readonly ProductCategorizationHelperService _productCategorization;
public class ProductRequest : IReturn<ProductRequestResponse> …
Run Code Online (Sandbox Code Playgroud) 我试过包装我的
<system.web>
Run Code Online (Sandbox Code Playgroud)
同
<location path="." InheritInChildApplications="false">
Run Code Online (Sandbox Code Playgroud)
像这样
<location path="." InheritInChildApplications="false">
<system.web>...</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
但VS 2010 Web Developer Express一直在说
不允许使用"InheritInChildApplications"属性
当我运行我的网络应用程序时出现错误:
HTTP错误500.19 - 内部服务器错误
无法访问请求的页面,因为页面的相关配置数据无效.配置错误无法识别的属性'InheritInChildApplications'.
我的配置:ASP.NET 4.0 RTM,VS 2010,IIS 7.5
我想创建一个静态类,它将从XML文件加载一些设置并将这些设置应用于它自己的属性.
我试图使用以下代码,但我真的不知道如何给SetValue方法,因为我们要设置属性的类是静态的.
// some code removed ...
Type settingsType = typeof(Settings); // Settings is a static class
foreach (PropertyInfo propertyInformation in settingsType.GetProperties(BindingFlags.Public |
BindingFlags.Static))
{
//------------------------------------------------------------
// Determine if configured setting matches current setting based on name
//------------------------------------------------------------
if (propertyInformation.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
{
//------------------------------------------------------------
// Attempt to apply configured setting
//------------------------------------------------------------
try
{
if (propertyInformation.CanWrite)
{
propertyInformation.SetValue(this, Convert.ChangeType(value, propertyInformation.PropertyType, CultureInfo.CurrentCulture), null);
}
}
catch
{
}
break;
}
Run Code Online (Sandbox Code Playgroud)
}
甚至可以使用反射在静态类上设置属性吗?
在SQL Server 2008及更高版本中,什么是最好/最安全/最正确的方法
asp.net-mvc ×5
.net ×2
asp.net ×2
c# ×2
web-config ×2
javascript ×1
nuget ×1
reflection ×1
regex ×1
servicestack ×1
sql ×1
sql-server ×1
static ×1