我需要从Web服务返回存储在磁盘上的映像.
在我的控制器中,我执行一些搜索操作并发送文件.这是我的代码.
public HttpResponseMessage Get([FromUri]ShowImageRequest req)
{
// .......................
// .......................
// load image file
var imgStream = new MemoryStream();
using (Image image = Image.FromFile(fullImagePath))
{
image.Save(imgStream, ImageFormat.Jpeg);
}
imgStream.Seek(0, SeekOrigin.Begin); // it does not work without this
var res = new HttpResponseMessage(HttpStatusCode.OK);
res.Content = new StreamContent(imgStream);
res.Content.Headers.ContentType = new ediaTypeHeaderValue("image/jpeg");
return res;
}
Run Code Online (Sandbox Code Playgroud)
如果我不添加这一行,我会在fiddler响应体长0中看到
imgStream.Seek(0, SeekOrigin.Begin);
Run Code Online (Sandbox Code Playgroud)
否则它有效.我错过了什么,为什么我需要这样做?
我是Mac上的Visual Studio的新手,有人可以显示我们可以在哪里运行终端窗口以执行一些git命令吗?
在我的dll中,一切都很好,直到今天,我不知道出了什么问题.从今天起出现错误的异常行数.
所以在我的方法里面的dll库我插入一行来抛出不支持的异常,但要么我使用调试器,要么只是看日志行中的异常行是错误的!
这是部分代码的图像:
事实上例外是在391线,这是很长的时间,直到今天.现在在日志中我看到776行,在调试器中也是如此.有人有什么想法吗?
更新1 05/11/2013
阅读完所有答案后(感谢大家为他们=))这里有一些更新:
pdb文件是最新的吗?我想是的,因为我从输出文件夹,重建解决方案中删除了所有内容并查看了相同的问题.我也检查了它的创建日期.
我处于发布模式吗?我认为不是.这是一个带有构建配置的图像
代码优化了吗?我创建了另一个测试并删除了NotSupportedException以下的所有内容,但问题仍然在方法的最后,行是397但不是391,就像我们实际上一样
什么是内部异常?空值

在我的Windows机器上,我安装了Visual Studio代码.要手动运行测试,我将进入项目文件夹并输入
go test main_test.go
Run Code Online (Sandbox Code Playgroud)
它完美地运作.
但我有一种情况需要调试我的测试以了解正在发生的事情.
为此,我打开launch.json并添加配置
{
"name": "Tests",
"type": "go",
"request": "launch",
"mode": "test",
"remotePath": "",
"port": 2346,
"host": "127.0.0.1",
"program": "${workspaceRoot}",
"env": {},
"args": [
"main_test.go"
],
"showLog": true
}
Run Code Online (Sandbox Code Playgroud)
按完F5后,我有
2017/03/29 13:28:11 server.go:73: Using API v1
2017/03/29 13:28:11 debugger.go:68: launching process with args: [./debug.test main_test.go main_go]
not an executable file
Process exiting with code: 1
Run Code Online (Sandbox Code Playgroud)
任何想法为什么会出现这个错误以及它正在寻找什么可执行文件?
@Autowired如果我使用构造函数 DI,是否必须放置?
在我的 Spring Boot 应用程序中,IntelliJ 向我显示了警告 Could not autowire. There is more than one bean of 'MyType' type.
实际上有两个 bean,但它们是根据属性定义的
@Service
@ConditionalOnProperty(name = "features.feature1", havingValue = "true")
public class Bean1 implements SomeInterface{
}
Run Code Online (Sandbox Code Playgroud)
而第二个依赖于相同的属性,application.yml但如果它被设置为false
@Service
@ConditionalOnProperty(name = "features.feature1", havingValue = "false", matchIfMissing = true)
public class Bean2 implements SomeInterface{
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让 IntelliJ 理解这一点而不显示警告?项目运行没有问题。
在 Spring Data Jpa 中获取前 10 行我可以做到这一点findTop10By...()。在我的情况下,数字或行没有定义,而是作为参数出现的。
有类似的东西findTopNBy...(int countOfRowsToGet)吗?
我想尝试在我的 Angular 11 组件中使用 css 变量。
<div class="main-content">
<a>Test Link</a>
</div>
Run Code Online (Sandbox Code Playgroud)
有了这个app.component.css
div.main-content{
--main-color: red
}
a{
color: var(--main-color);
}
Run Code Online (Sandbox Code Playgroud)
但如果我尝试:root在我的 css 中使用链接是黑色的。
:root {
--main-color: red
}
a{
color: var(--main-color);
}
Run Code Online (Sandbox Code Playgroud)
:root 选择器匹配文档的根元素。
为什么它与我的情况不匹配?
更新如果我在全局包含的角度项目中设置:root默认值,则一切正常。styles.css我的怎么了app.component.css?
c# ×2
android ×1
angular ×1
autowired ×1
css ×1
exception ×1
go ×1
line ×1
memory-leaks ×1
memorystream ×1
profiler ×1
spring-boot ×1
spring-data ×1
stack-trace ×1
switchcompat ×1
unit-testing ×1