我的应用程序概述:在客户端,使用网络摄像头拍摄一系列快照.提交时,我希望将图像转换为字节数组,并将该字节数组发送到我编写的服务.
我的问题:我正在尝试将单个图像保存到a MemoryStream,但它继续破坏,吐出消息"GDI +中发生了一般错误." 当我深入挖掘时,我看到当MemoryStream的缓冲区位置为54时抛出异常.不幸的是,它是一张1.2 mb照片.这是代码块:
// Create array of MemoryStreams
var imageStreams = new MemoryStream[SelectedImages.Count];
for (int i = 0; i < this.SelectedImages.Count; i++)
{
System.Drawing.Image image = BitmapFromSource(this.SelectedImages[i]);
imageStreams[i] = new MemoryStream();
image.Save(imageStreams[i], ImageFormat.Bmp); /* Error is thrown here! */
}
// Combine MemoryStreams into a single byte array (Threw this
// in in case somebody has a better approach)
byte[] bytes = new byte[imageStreams.Sum(s => s.Length)];
for(int i = 0; i < imageStreams.Length; …Run Code Online (Sandbox Code Playgroud) 我正在编写WPF和Silverlight中使用的代码.在C#中我可以"#if SILVERLIGHT"用于条件编译,它可以工作.
但是,在XAML中,我必须使用完全不同的XAML文件,因为某些属性只是不兼容.XAML文件是99%的类似,并保持同步是一个麻烦.
我想将它们转换为T4模板,所以我可以做以下事情:
<SomeControl <#=ClipsToBounds()#> />
Run Code Online (Sandbox Code Playgroud)
哪里ClipsToBounds()为WPF和Silverlight生成不同的文本.要求是:
我发现我可以更改custom toolXAML文件MSBuild:Compile to TextTemplatingFileGenerator,但我不会丢失Intellisense.但是,生成的模板是在设计时生成的.然后在构建时生成似乎是一个巨大的痛苦.
有没有人有这种设置的成功经验?
我通过MVC5安装了GlimpseInstall-Package Glimpse.MVC5
我在Glimpse配置页面上打开了Glimpse: /Glimpse.axd
当试图现在访问我的网站时,没有任何反应.如果我关闭Glimpse,该网站将按预期工作.
Chrome网络工具中没有任何错误消息或任何http相关信息,只有以下请求:data:text/html,chromewebdata响应为"Failed to load response data"
这是Glimpse在我安装它时放入web.config的内容.不知道如何解决这个问题.
<httpModules>
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
</httpModules>
<httpHandlers>
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
</httpHandlers>
<modules>
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
<handlers>
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
Run Code Online (Sandbox Code Playgroud) 根据要求,编辑以提供更多详细信息
我有一个存储过程(让我们调用它spOuter)沿着以下行:
ALTER PROCEDURE [dbo].[spOuter]
(@SelFromDateUTC smalldatetime
,@SelToDateUTC smalldatetime
,@SelDriverId int = null
) AS
DECLARE @SelDriverName varchar(40)
Set Nocount on
exec dbo.spInner --<<<<<<<<<<<<<<<<<<<<<<<<<<<
Select @SelDriverName = DriverName
From dbo.tblDrivers
Where DriverID = @SelDriverId
Set Nocount off
Select @SelToDateUTC as @SelShiftDateUTC
,@SelDriverName as SelDriverName
, *
From dbo.vwRptDriverProgress
Where ActionTimeUTC between @SelFromDateUTC and @SelToDateUTC
and DriverId = coalesce(@SelDriverId, DriverId)
Order by DriverName,ActionTimeUTC,DriverLogId
Run Code Online (Sandbox Code Playgroud)
当我spInner从SSMS 运行时,它不会返回任何结果集.但是,当我运行它时,spOuter我得到两个结果集,一个来自spInner和一个spOuter(注释掉调用以spInner删除多余的结果集).
spInner 如下:
ALTER PROCEDURE …Run Code Online (Sandbox Code Playgroud) 我正在使用"HotTowel"单页应用模板,但我无法使SignalR正常工作.我收到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8184/signalr/hubs
Run Code Online (Sandbox Code Playgroud)
我有一种使用标准MVC 4单页面应用程序的样板,有一个非常简单的集线器(用户在线计数器).一切都很好.
切换到"HotTowel"后,它停止工作.我和John Papa一起检查过,他给了我一个建议来检查Durandal方面,因为他提到他知道在一些干扰某些路由的问题上要做一些修复.
main.js:
require.config({
paths: {
"text": "durandal/amd/text",
"signr": "../scripts/jquery.signalR-1.0.1.min"
}
});
define(['durandal/app', 'durandal/viewLocator', 'durandal/system', 'durandal/plugins/router', 'services/logger', "signr"],
function (app, viewLocator, system, router, logger, sigr) {
// Enable debug message to show in the console
system.debug(true);
app.start().then(function () {
toastr.options.positionClass = 'toast-bottom-right';
toastr.options.backgroundpositionClass = 'toast-bottom-right';
router.handleInvalidRoute = function (route, params) {
logger.logError('No Route Found', route, 'main', true);
};
// When finding a …Run Code Online (Sandbox Code Playgroud) 我正在设置一个GenericPrincipal添加GenericIdentity& 角色,但是当我尝试从中检索角色时,我什么也没得到。但是,如果我调用Principal.IsInRole,它会返回正确的值。
我错过了什么?
var identity = new GenericIdentity("Test", "Test");
var pricipal = new GenericPrincipal(identity, new[] { "Role1", "Role2" });
var cls = identity.Claims
.Where(c => c.Type == ClaimTypes.Role)
.Select(c => c.Value);
foreach(var c in cls)
{
Console.WriteLine(c);
}
Console.WriteLine("complete");
Run Code Online (Sandbox Code Playgroud) 我写了一些java代码来计算2点之间的距离.由于一些奇怪的原因,它不收集输入也没有找到距离,这就是我试图做的事情.有人可以帮助我,这是我的代码:
import java.util.Scanner;
public class Distance
{
static double distance(double x1, double y1, double x2, double y2) {
return Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
}
public static void main(String[] args) {
double x2, x1, y2, y1;
double distance;
Scanner scan = new Scanner (System.in);
System.out.println("Enter two points: ");
x1 = scan.nextDouble();
y1 = scan.nextDouble();
x2 = scan.nextDouble();
y2 = scan.nextDouble();
distance = distance(x1, y1, x2, y2);
System.out.println("The distance between the two points is " + distance + " .");
}
}
Run Code Online (Sandbox Code Playgroud) 我想在页面中淡出消息,然后淡出以显示用户登录登录的用户,然后重定向到配置文件,但消息刚出现在屏幕上没有淡入淡出,但它确实消失了很好.
这是我的代码:
echo "
<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\">
</script>
<script>
$(function() {
$('button').click(function() {
$('p').fadeIn(3000);
$('p').fadeOut(5000);
});
});
</script>";
$error = "<meta http-equiv='refresh' content='100; Me'>
<p style='font-weight:bold;color:green;padding:3px;'>Welcome back $name!</p>";
Run Code Online (Sandbox Code Playgroud)