可能重复:
找不到git:命令
如何将/ usr/local/git/bin /添加到mac osx上的PATH?我刚刚安装了git但它没有识别命令.它只响应"命令git not found",我相信这可能是解决方案,但我不知道如何将它添加到终端中使用的路径.
您好,并提前感谢您的帮助,我知道这个问题或类似的问题已经发布,经常对MVC 3应用程序有特殊的关注.但是,每当我尝试使用.net 4.0目标框架从visual web developer express 2010中启动任何应用程序时,我都会收到此错误消息.
确切的错误消息是:
尝试使用安全透明方法'System.Runtime.Diagnostics.DiagnosticTrace..ctor(System.String,System.Guid)'来访问安全关键方法'System.Runtime.Diagnostics.EtwDiagnosticTrace..ctor(System.String,System.Guid) )'失败'.
大会"System.ServiceModel.Internals,版本= 4.0.0.0,文化=中性公钥= 31bf3856ad364e35"标有AllowPartiallyTrustedCallersAttribute程序,并使用2级安全透明度模式.2级透明度导致AllowPartiallyTrustedCallers程序集中的所有方法默认情况下变为透明安全性,这可能是此异常的原因.
堆栈跟踪:
[MethodAccessException: Attempt by security transparent method 'System.Runtime.Diagnostics.DiagnosticTrace..ctor(System.String, System.Guid)' to access security critical method 'System.Runtime.Diagnostics.EtwDiagnosticTrace..ctor(System.String, System.Guid)' failed.
Assembly 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.]
System.Runtime.Diagnostics.DiagnosticTrace..ctor(String traceSourceName, Guid etwProviderId) +24
System.ServiceModel.Activation.FxTrace.InitializeTracing() +90
System.ServiceModel.Activation.FxTrace.get_Trace() +84 …Run Code Online (Sandbox Code Playgroud) 您好,并提前感谢您的帮助.尝试使用XmlSerializer和StringReader将XElement反序列化为对象时遇到问题.我的反序列化代码是这样的:
/*deseierialize a single RegisterServerObject instance from xml*/
static RegisterServerObject DeserializeSingleServerFromXml(XElement serverElement)
{
XmlSerializer deserializer = new XmlSerializer(typeof(RegisterServerObject));
RegisterServerObject server;
using (var reader = new StringReader(serverElement.ToString()))
server = (RegisterServerObject)deserializer.Deserialize(reader);
return server;
}
Run Code Online (Sandbox Code Playgroud)
我知道例外所揭示的读者内容是:
<Server>
<ServerID>11</ServerID>
<GroupID />
<ParentID>15</ParentID>
<ServerName>IAProd1</ServerName>
<User>admin</User>
<UID>123</UID>
<PWD>password</PWD>
<Domain>InputAccel</Domain>
<Location>Left</Location>
<AssociatedModules>
<Module>
<ModId>1</ModId>
<ServerId>11</ServerId>
<ModName>TestModA</ModName>
<ModuleStatus>1</ModuleStatus>
</Module>
<Module>
<ModId>2</ModId>
<ServerId>11</ServerId>
<ModName>TestModB</ModName>
<ModuleStatus>1</ModuleStatus>
</Module>
<Module>
<ModId>9</ModId>
<ServerId>11</ServerId>
<ModName>TestModI</ModName>
<ModuleStatus>1</ModuleStatus>
</Module>
<Module>
<ModId>10</ModId>
<ServerId>11</ServerId>
<ModName>TestModJ</ModName>
<ModuleStatus>1</ModuleStatus>
</Module>
</AssociatedModules>
</Server>
Run Code Online (Sandbox Code Playgroud)
我的RegisterServerObject类如下所示:
[XmlRoot("Server")]
public class RegisterServerObject
{
public RegisterServerObject() { …Run Code Online (Sandbox Code Playgroud) 我想优化我的团队用于应用程序的数据库的性能.
我一直在寻找添加外键的区域,然后索引这些列以提高连接的性能.但是,我们的许多表都是在一个GUID类型的id上连接,在插入项目时生成,而与其他表中的该项目相关联的数据通常具有item_id包含GUID的列.
我已经读过,将聚簇索引添加到GUID类型列是一个非常糟糕的决定,因为索引需要不断重建才能生效.但是,我想知道,在上述场景中使用非聚集索引是否有任何不利影响?或者假设它有助于提高性能是否合理?如果需要,我可以提供更多信息.
我想使用存储过程将作为参数传入的一些值插入到列的xml中的元素中.到目前为止我有这个以下参数:
@profile_id int,
@user_id nvarchar(50),
@activity_name nvarchar(50),
@display_name nvarchar(50)
Run Code Online (Sandbox Code Playgroud)
检索所需的xml:
DECLARE @profiles_xml xml
SET @profiles_xml = (SELECT profiles from tbl_applied_profiles WHERE profiles.value('(Profile/ID)[1]','int')= @profile_id)
Run Code Online (Sandbox Code Playgroud)
@profiles_xml中的列中的xml如下所示:
<Profile>
<ID>20</ID>
<User>
<ID>BC4A18CA-AFB5-4268-BDA9-C990DAFE7783</ID>
<Name>somename</Name>
<Activities>
<Activity>
<Name>activity1</Name>
</Activity>
</Activities>
</User>
</Profile>
Run Code Online (Sandbox Code Playgroud)
尝试使用特定ID向活动用户名和显示名称插入用户:
SET @profiles_xml.modify('
insert
if(/Profile/User/ID=sql:variable("@user_id"))
then Activity[Name=sql:variable("@activity_name")][DisplayName=sql:variable("@display_name")]
else()
as first
into (/Profile/User/Activities)[1]')
Run Code Online (Sandbox Code Playgroud)
我也试过这个没有成功:
SET @devices_xml.modify('
insert /Profile/User[ID=sql:variable("@user_id")]/Activity[Name=sql:variable("@activity_name")][DisplayName=sql:variable("@display_name")]
into (/Profile/User/Activities)[1]')
Run Code Online (Sandbox Code Playgroud)
还有这个:
SET @devices_xml.modify('
insert
/Profile/User[ID=sql:variable("@user_id")]/Activities/Activity[Name=sql:variable("@activity_name")][DisplayName=sql:variable("@display_name")]
into (/Profile/User/Activities)[1]')
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?
我有一个Silverlight应用程序,它通过WCF服务与服务器端的ADO.Net数据实体进行通信.实际上,我使用多个WCF服务与三个不同的数据ADO.Net数据实体进行通信.我最初在Visual Studio 2010上构建了这个项目,最近大约一周前转移到了Visual Studio Professional 2012(试用版).最初工作/移植的一切都很好,直到大约一小时前,我对服务没有任何问题.不到一小时前,我在我的代码中使用了这些相同的WCF服务.但是,当我添加一个方法将xml字符串插入我的数据库时,我收到此错误:
Content Type text/xml; charset=utf-8 was not supported by service . The client and service bindings may be mismatched.
Run Code Online (Sandbox Code Playgroud)
但我检查了绑定,从ServiceReferences.ClientConfig文件中我可以看出它们是basicHttpBinding.我四处寻找解决方案,我唯一能找到的建议是在重启Visual Studio后删除服务引用并读取它,所以我终于尝试了,但是现在,即使删除了我添加的方法,我现在也会收到此错误我尝试在客户端上添加服务引用:
Warning 6 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Exception has been thrown by the target of an invocation.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IXMonitorXMLDataService'] C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap 1 1 SL_xMonitor_Frontend_RefactorV1
Warning 7 Custom tool warning: Cannot import wsdl:binding
Detail: There was …Run Code Online (Sandbox Code Playgroud) 在Microsoft SQL Server 2008中,我尝试将值插入到sql表中,其中包含数据类型为int的type_id列和数据类型为XML的xml_info.我使用以下查询:
INSERT INTO tbl_applied_devices ([type_id],[xml_info])
VALUES (1,'<Profile ID=99><Server><ID>BC4A18CA-AFB5-4268-BDA9-C990DAFE7783</ID> <Name>localhost</Name><Services></Services></Server></Profile>')
Run Code Online (Sandbox Code Playgroud)
但我一直收到这个错误:
消息9413,级别16,状态1,行4
XML解析:第1行,字符13,字符串文字是预期的
我做错了什么?
编辑:
我发现了错误的来源是XML元素的ID属性,<Profile ID=99>似乎是什么原因造成的错误.如何正确插入带属性的xml?我是否需要以某种方式逃脱其中一个角色?
我试图插入一些xml我从表中的列中检索.我按如下方式检索它:
DECLARE @profiles_xml xml
DECLARE @profile_id int
SET @profile_id = 16
SET @profiles_xml = (SELECT profiles from tbl_applied_profiles WHERE
profiles.value('(Profile/ID)[1]','int')= @profile_id)
Run Code Online (Sandbox Code Playgroud)
生成的xml如下所示:
<Profile>
<ID>16</ID>
<User>
<ID>BC4A18CA-AFB5-4268-BDA9-C990DAFE7783</ID>
<Name>test</Name>
<Activities />
</User>
</Profile>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将元素插入其中时,如下所示:
SET @devices_xml.modify('insert <Activity><Name>testname</Name></Activity>
as first into (Profiles/User/Activities[1])')
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
XQuery [modify()]: The target of 'insert' must be a single node, found 'element(Activities,xdt:untyped) *'
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会出现错误,因为目前只有一个Activities元素.
我有两张桌子:
tbl_profiles_and_users:
[id] [int] IDENTITY(1,1) NOT NULL,
[profile_id] [int] NOT NULL,
[user_id] [nvarchar](50) NULL
Run Code Online (Sandbox Code Playgroud)
tbl_profiles_and_activities:
[id] [int] IDENTITY(1,1) NOT NULL,
[profile_id] [int] NOT NULL,
[user_id] [nvarchar](50) NOT NULL,
[activity_name] [nvarchar](50) NULL,
[check] [int] NULL,
[preferred] [int] NULL
Run Code Online (Sandbox Code Playgroud)
两个表都有条目,我试图只从指定的配置文件中选择用户和活动.
我试图通过以下连接执行此操作:
use [dbName]
SELECT p1.user_id AS User_ID, [p2.activity_name] as [Activity_Name]
FROM tbl_profiles_and_users AS p1
INNER JOIN tbl_profiles_and_activities AS p2
ON p1.user_id = p2.user_id AND p1.profile_id = p2.profile_id
Run Code Online (Sandbox Code Playgroud)
但我收到消息无效列名'p2.activity_name'我做错了什么?我可以通过加入达到预期的效果吗?
我有一个用C#编写的应用程序,我试图将一些信息写入隐藏的ProgramData,以便从应用程序的前端和后端访问相同的连接字符串.
我使用路径变量访问目录,如下所示:
private bool ProgramDataWriteFile(string contentToWrite)
{
try
{
string strProgramDataPath = "%PROGRAMDATA%";
string directoryPath = Environment.ExpandEnvironmentVariables(strProgramDataPath) + "\\MyApp\\";
string path = Environment.ExpandEnvironmentVariables(strProgramDataPath)+"\\MyApp\\ConnectionInfo.txt";
if (Directory.Exists(directoryPath))
{
System.IO.StreamWriter file = new System.IO.StreamWriter(path);
file.Write(contentToWrite);
file.Close();
}
else
{
Directory.CreateDirectory(directoryPath);
System.IO.StreamWriter file = new System.IO.StreamWriter(path);
file.Write(contentToWrite);
file.Close();
}
return true;
}
catch (Exception e)
{
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
这似乎工作正常.但是,我的问题是,当我使用这个路径变量时:%AllUsersProfile%(%PROGRAMDATA%)
相反,它扩展为非法(和冗余)文件路径:C:\ProgramData(C:\ProgramData)\
但是,我认为后一个路径变量是正确的全名.我只是错误地使用它吗?我需要确保所有用户都可以访问此连接信息,只是使用%PROGRAMDATA%allow?我正在使用Windows 7,以防相关.
我在SQL Server 2008中进行DATEDIFF()调用,作为存储过程的一部分,它可能返回小至3秒或更短的值.我希望格式为MM:SS(即3秒时00:03).我最初在几分钟内使用了这个电话:
DATEDIFF(mi, SELECT MAX(startDate) FROM myTable , SELECT MAX(EndDate) FROM myTable)
但是,这会向下舍入到最近的分钟,从而消除秒值.如何使用DATEDIFF实现上面指定的格式?
我有一个看起来像这样的查询:
use [dbName]
DECLARE @profile_id int
SET @profile_id = 18
DECLARE @test int
SET @test = (SELECT user_profile_id FROM tbl_profiles WHERE id = @profile_id)
SELECT @test as test
if @test = NULL
SELECT 1
else
SELECT 2
Run Code Online (Sandbox Code Playgroud)
我知道表中的值为null,我可以看到@test正确设置为该值,因为第一个SELECT显示:
|test
1|NULL
Run Code Online (Sandbox Code Playgroud)
但是,在IF条件下,变量不会被视为NULL,因为只返回第三个SELECT,显示:
|(no column name)
1| 2
Run Code Online (Sandbox Code Playgroud)
这是为什么?
在我的团队ASP.NET应用程序的数据访问层中,我通过使用.NET SQLClient对我们的数据库运行存储过程.添加新代码以允许对数据库进行插入操作后,我测试了代码,并收到以下异常:
The transaction log for database 'DBName' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
我确认在从MS SQL Server Management Studio中尝试插入操作时收到相同的消息.我很担心,因为我最近在数据库中添加了三个两个触发器来执行基于对某些表的插入和更新的一些数据插入,我认为可能是我遇到了无限循环或者那种性质的东西.
但是,基于此问题的其他在线实例,它似乎不是通常由触发器或旋转查询引起的问题.我查询了log_reuse_wait和log_reuse_wait_desc列并返回以下内容:
2 | LOG_BACKUP
此外,查询返回:SELECT [name], recovery_model_desc, log_reuse_wait_desc
FROM sys.databases
name | recovery_model_desc| log_reuse_wait_desc
DBName| FULL | LOG_BACKUP
Run Code Online (Sandbox Code Playgroud)
其中第一列是log_reuse_wait第二列,第二列是log_reuse_wait_desc.根据msdn上代码的定义,我需要执行日志备份,然后日志可以自动截断,从而允许对数据库进行进一步操作.这是正确的假设吗?这是由错误编码的触发器引起的,还是更多的例行维护任务,是由数据库上的大量事务引起的?
编辑:
查询select type_desc, size, max_size from sys.database_files返回:
type_desc | size | max_size
1| ROWS | 512 …Run Code Online (Sandbox Code Playgroud) t-sql database sql-server transaction-log sql-server-2005-express
t-sql ×8
c# ×4
xml ×4
.net ×3
sql ×3
sql-server ×3
xquery ×2
.net-4.0 ×1
asp.net ×1
database ×1
datediff ×1
datetime ×1
filepath ×1
foreign-keys ×1
git ×1
if-statement ×1
indexing ×1
inner-join ×1
insert ×1
join ×1
macos ×1
null ×1
optimization ×1
silverlight ×1
wcf ×1