我正在使用我的应用程序部署sql express.我希望该数据库引擎接受远程连接.我知道如何通过启动sql server配置管理器,启用tcp/ip连接,指定端口等来配置该手册.我想知道是否可以从命令行执行相同的操作.
或许我必须在visual studio中创建一个"SQL Server 2008 Server Project".
我在这里发布了相同的问题,但我想在已经安装的sql express实例上做同样的事情.看看这里的问题
我发现这些链接声称做了类似的事情,但我仍然无法使其发挥作用.
1)http://support.microsoft.com/kb/839980
4)http://datazulu.com/blog/post/Enable_sql_server_tcp_via_script.aspx
正如Krzysztof在他的回答中所说,我需要(以及我所知道的其他需要的东西)
1 - 启用TCP/IP

我已经设法在安装传递参数的SQLExpress的新实例时执行此操作 /TCPENABLED=1.当我在这个例子中安装sql express时.sql express的实例将启用TCP/IP
2 - 在防火墙中打开正确的端口
(我已经完成了这个manualy,但我相信我将能够弄清楚如何用c#来做到这一点)到目前为止,我必须使用这个控制台命令来解决问题:
netsh firewall set portopening protocol = TCP port = 1433 name = SQLPort mode = ENABLE scope = SUBNET profile = CURRENT
Run Code Online (Sandbox Code Playgroud)
3 - 修改TCP/IP属性启用IP地址

我一直无法弄清楚如何启用IP,更改端口等.我认为这将是更复杂的解决步骤
4 - 在sql server中启用混合模式身份验证

我已经设法在安装SQL Express时执行此操作,传递参数/SECURITYMODE=SQL参考步骤1的链接.
SQL Server Express要求此身份验证类型接受远程连接.
5 - 更改用户(sa)默认passowrd …
configuration cmd database-connection remote-connection sql-server-express
我想将日期作为数字存储在表格中.我知道怎么做,但我不知道怎么回去.如何将长变量强制转换为ToDateTime.
DateTime now = DateTime.Now;
long t = now.ToFileTime();
DateTime today = t.ToDateTime; // I am looking for something like this line. This Method does not exist
Run Code Online (Sandbox Code Playgroud)
我知道有很多方法可以将DateTime转换为long.我不介意使用哪种技术.我只想有一种方法可以来回转换.
为什么以下代码不起作用:
class Program
{
static void Main ( string[ ] args )
{
SomeClass s = new SomeClass( );
s.GetType( ).GetField( "id" , System.Reflection.BindingFlags.NonPublic ) // sorry reasently updated to GetField from GetProperty...
.SetValue( s , "new value" );
}
}
class SomeClass
{
object id;
public object Id
{
get
{
return id;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图设置私有字段的值.
这是我得到的例外:
System.NullReferenceException未处理Message = Object引用未设置为对象的实例.来源= ConsoleApplication7
StackTrace:位于C:\ Users\Antonio\Desktop\ConsoleApplication7\ConsoleApplication7\Program.cs中的Program.Main(String [] args):位于System的System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String [] args)的第18行. System.Threading.ExecutionContext.Run上的System.Threading.ThreadHelper.ThreadStart_Context(Object state)中的Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()中的AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)(ExecutionContext executionContext System.Threading.ThreadHelper.ThreadStart()中的System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态),ContextExallback回调,对象状态,布尔值ignoreSyncCtx:InnerException:
当我放置一个img标签时,我动态创建了src属性.有没有办法测试src(图像所在的路径)是否实际存在于javascript中以避免获取:

我使用这块板作为键盘用于演示目的.
无论如何,长话短说一切都很好,除了很少的情况.我使用user32.dll中的SendInput函数发送击键.
所以我的程序看起来像:
static void Main(string[] args)
{
Console.Write("Press enter an on the next secont the key combination shift+end will be send");
Console.Read();
Thread.Sleep(1000);
SendKeyDown(KeyCode.SHIFT);
SendKeyPress(KeyCode.END);
SendKeyUp(KeyCode.SHIFT);
Console.Read();
Console.Read();
}
[DllImport("user32.dll", SetLastError = true)]
private static extern uint SendInput(uint numberOfInputs, INPUT[] inputs, int sizeOfInputStructure);
/// <summary>
/// simulate key press
/// </summary>
/// <param name="keyCode"></param>
public static void SendKeyPress(KeyCode keyCode)
{
INPUT input = new INPUT {
Type = 1
};
input.Data.Keyboard = new KEYBDINPUT() { …Run Code Online (Sandbox Code Playgroud) 我有一个使用对称加密来加密和解密数据的算法.无论如何,当我要解密时,我有:
CryptoStream cs = new CryptoStream(ms, cryptoTransform, CryptoStreamMode.Read);
Run Code Online (Sandbox Code Playgroud)
我必须从cs CryptoStream中读取数据并将该数据放入一个字节数组中.所以一种方法可能是:
System.Collections.Generic.List<byte> myListOfBytes = new System.Collections.Generic.List<byte>();
while (true)
{
int nextByte = cs.ReadByte();
if (nextByte == -1) break;
myListOfBytes.Add((Byte)nextByte);
}
return myListOfBytes.ToArray();
Run Code Online (Sandbox Code Playgroud)
另一种技术可能是:
ArrayList chuncks = new ArrayList();
byte[] tempContainer = new byte[1048576];
int tempBytes = 0;
while (tempBytes < 1048576)
{
tempBytes = cs.Read(tempContainer, 0, tempContainer.Length);
//tempBytes is the number of bytes read from cs stream. those bytes are placed
// on the tempContainer array
chuncks.Add(tempContainer);
}
// later do …Run Code Online (Sandbox Code Playgroud) 如果我有一个模式设置为居中的UIImageView,例如如何将其更改为其他内容,例如方面适合代码?

我发现7-zip很棒,我想在.net应用程序上使用它.我有一个10MB的文件(a.001),它需要:

2秒编码.
如果我能在c#上做同样的事情,那将会很好.我已经下载了http://www.7-zip.org/sdk.html LZMA SDK c#源代码.我基本上将CS目录复制到visual studio中的控制台应用程序中:

然后我编译和eveything编译顺利.所以在输出目录中我放置了a.00110MB大小的文件.关于我放置的源代码的主要方法:
[STAThread]
static int Main(string[] args)
{
// e stands for encode
args = "e a.001 output.7z".Split(' '); // added this line for debug
try
{
return Main2(args);
}
catch (Exception e)
{
Console.WriteLine("{0} Caught exception #1.", e);
// throw e;
return 1;
}
}
Run Code Online (Sandbox Code Playgroud)
当我执行控制台应用程序时,应用程序运行良好,我得到a.7z工作目录上的输出.问题是需要很长时间.执行大约需要15秒!我也试过/sf/answers/614314921/方法,这也需要很长时间.为什么它比实际程序慢10倍?
即使我设置只使用一个线程:

它仍然需要更少的时间(3秒对15):
可能是因为C#比汇编还是C慢?我注意到该算法执行了大量繁重的操作.例如,比较这两个代码块.他们都做同样的事情:
#include <time.h>
#include<stdio.h>
void main()
{
time_t now;
int i,j,k,x;
long …Run Code Online (Sandbox Code Playgroud) 我需要使用AES加密数据.在研究时我发现了AesCryptoServiceProvider类.
我对加密知之甚少,我不知道初始化向量(IV)是什么,所以我尝试在堆栈溢出中搜索AES示例,这引出了我的这个问题.
为什么堆栈溢出链接使用RijndaelManaged类?是RijndaelManaged的和AesCryptoServiceProvider类做同样的事情?
c# ×7
.net ×2
performance ×2
7zip ×1
aes ×1
cmd ×1
code-behind ×1
compression ×1
datetime ×1
encryption ×1
html ×1
image ×1
ipad ×1
iphone ×1
javascript ×1
lzma ×1
objective-c ×1
reflection ×1
sendinput ×1
sendkeys ×1
src ×1
stream ×1
treeview ×1
uiimageview ×1
user32 ×1
wpf ×1