对于我的生活,我无法让SqlProfileProvider在我正在进行的MVC项目中工作.
我意识到的第一个有趣的事情是Visual Studio不会自动为您生成ProfileCommon代理类.这不是什么大问题,因为扩展ProfileBase类只是简单的事情.在创建了ProfileCommon类之后,我编写了以下用于创建用户配置文件的Action方法.
[AcceptVerbs("POST")]
public ActionResult CreateProfile(string company, string phone, string fax, string city, string state, string zip)
{
    MembershipUser user = Membership.GetUser();
    ProfileCommon profile = ProfileCommon.Create(user.UserName, user.IsApproved) as ProfileCommon;
    profile.Company = company;
    profile.Phone = phone;
    profile.Fax = fax;
    profile.City = city;
    profile.State = state;
    profile.Zip = zip;
    profile.Save();
    return RedirectToAction("Index", "Account"); 
}Run Code Online (Sandbox Code Playgroud)
我遇到的问题是对ProfileCommon.Create()的调用无法转换为类型ProfileCommon,因此我无法取回我的配置文件对象,这显然导致下一行失败,因为配置文件为空.
以下是我的web.config的片段:
<profile defaultProvider="AspNetSqlProfileProvider" automaticSaveEnabled="false" enabled="true">
    <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" applicationName="/" />
    </providers>
    <properties>
        <add name="FirstName" type="string" />
        <add name="LastName" type="string" …Run Code Online (Sandbox Code Playgroud) 我试图在我的maven项目中包含一些依赖项.这些依赖项在默认的Mven 2存储库http://repo1.maven.org/maven2/中不可用.
它们可在http://mvnrepository.com/上找到
但是我找不到此站点的配置文件以包含在我的settings.xml中
有谁知道这个存储库的网址和个人资料是什么?
谢谢.
我正在尝试使用gcov编译一个简单的应用程序并获得以下链接错误:
gcc AllTests.o CuTestTest.o CuTest.o -o TestTest
AllTests.o: In function `global constructors keyed to 0_RunAllTests':
/home/p7539c/cutest/AllTests.c:26: undefined reference to `__gcov_init'
AllTests.o:(.data+0x44): undefined reference to `__gcov_merge_add'
CuTestTest.o: In function `global constructors keyed to 0_TestCuStringNew':
/home/p7539c/cutest/CuTestTest.c:30: undefined reference to `__gcov_init'
CuTestTest.o:(.data+0x64): undefined reference to `__gcov_merge_add'
CuTest.o: In function `global constructors keyed to 0_CuStrAlloc':
/home/p7539c/cutest/CuTest.c:379: undefined reference to `__gcov_init'
CuTest.o:(.data+0x184): undefined reference to `__gcov_merge_add'
collect2: ld returned 1 exit status
make: *** [TestTest] Error 1
Run Code Online (Sandbox Code Playgroud)
我似乎找不到丢失符号的位置.gcov存在于运行gcc 4.1.2版的机器上
有任何想法吗?谢谢.
在编辑:
将gcov与包含一个.c文件的应用程序一起使用时,一切似乎都能正常工作.当我有多个.c文件(因此有多个.o文件)时,我遇到了上述问题.
编译步骤如下所示:
cc -fprofile-arcs …Run Code Online (Sandbox Code Playgroud) 我有一个Web应用程序Maven项目,我想根据正在运行的配置文件自定义web.xml文件.我正在使用Maven-War-plugin,它允许我定义一个"资源"目录,可以过滤文件.但是,单独过滤对我来说还不够.
更详细地说,我希望包括(或排除)整个安全部分,具体取决于我正在运行的配置文件.这是部分:
....
....
<security-constraint>
    <web-resource-collection>
        <web-resource-name>protected</web-resource-name>
        <url-pattern>/pages/*.xhtml</url-pattern>
        <url-pattern>/pages/*.jsp</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>*</role-name>
    </auth-constraint>
    </security-constraint>
        <login-config>
        <auth-method>${web.modules.auth.type}</auth-method>
        <realm-name>MyRealm</realm-name>
    </login-config>
<security-constraint>
....
....
Run Code Online (Sandbox Code Playgroud)
如果不能轻松完成,有没有办法获得两个web.xml文件并根据配置文件选择合适的文件?
我正在使用Selenium Web Driver API和Java.每次我想调试我的测试用例时,都会在临时文件目录中创建Firefox的临时配置文件.这在两个方面令人头疼.
我该如何解决这个问题?
我不知道为什么,但是当我试图获取用户的个人资料图片时,我总是变为空.我是否需要设置一些特定权限才能获得访问权限?
以下是我的方法:
public static Bitmap getFacebookProfilePicture(String userID) throws SocketException, SocketTimeoutException, MalformedURLException, IOException, Exception
{
   String imageURL;
   Bitmap bitmap = null;
   imageURL = "http://graph.facebook.com/"+userID+"/picture?type=large";
   InputStream in = (InputStream) new URL(imageURL).getContent();
   bitmap = BitmapFactory.decodeStream(in);
   return bitmap;
}
Bitmap bitmap = getFacebookProfilePicture(userId);
Run Code Online (Sandbox Code Playgroud)
我变得空了.我不知道原因是什么?任何帮助都很明显.
我们已经成立了几个发布了用于网络应用程序部署到不同的服务器配置文件,而这一切与1键式部署的伟大工程.
然而,我们发现,尽管整个解决方案的源代码控制(SVN)下,似乎是配置文件不结转,所以我们需要手动重新创建每个开发人员的机器上的配置文件.
似乎由于配置文件仅存在于当前加载的解决方案中,因此它们必须存储在某处的解决方案文件中.但是,当其他人进行更新以下拉代码时,它们不会延续.
我猜他们是在什么文件是一个我们没有在源代码控制项目覆盖,但我一直没能找出哪一个.
有人必须知道发布配置文件的存储位置.有没有办法从机器到机器复制它们,这样我们就不必为每个开发人员重新键入它们?
我有一个Web应用程序,我有一个典型的问题,它需要不同环境的不同配置文件.某些配置作为JNDI数据源放置在应用程序服务器中,但某些配置保留在属性文件中.
因此,我想使用Spring配置文件功能.
我的问题是我没有运行测试用例.
context.xml中:
<context:property-placeholder 
  location="classpath:META-INF/spring/config_${spring.profiles.active}.properties"/>
Run Code Online (Sandbox Code Playgroud)
测试用例:
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
    TestPreperationExecutionListener.class
    })
@Transactional
@ActiveProfiles(profiles = "localtest")
@ContextConfiguration(locations = {
    "classpath:context.xml" })
public class TestContext {
  @Test
  public void testContext(){
  }
}
Run Code Online (Sandbox Code Playgroud)
问题似乎是加载配置文件的变量未解决:
Caused by: java.io.FileNotFoundException: class path resource [META-INF/spring/config_${spring.profiles.active}.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:138)
... 31 more
Run Code Online (Sandbox Code Playgroud)
应使用@ActiveProfile注释设置当前配置文件.因为它是一个测试用例,我将无法使用web.xml.如果可能的话,我也想避免运行时选项.测试应按原样运行(如果可能).
如何正确激活配置文件?是否可以使用context.xml设置配置文件?我可以在test-context.xml中声明实际调用普通上下文的变量吗?
我想从脚本文件重新加载我的用户配置文件.我认为从脚本文件中获取点可以解决这个问题,但它不起作用:
# file.ps1
. $PROFILERun Code Online (Sandbox Code Playgroud)
但是,如果我从PowerShell的解释器中获取它,它确实有效.
我为什么要这样做?
我每次更新我的配置文件并且想要测试它时都会运行此脚本,因此我希望避免重新启动PowerShell来刷新环境.
这是我的PS1变量:
PS1='\u:\W$(__git_ps1 "\e[32m\][%s]\e[0m\]")$ '
Run Code Online (Sandbox Code Playgroud)
非常适合拾取我的Git分支,但它在颜色处于活动状态时包裹线条会产生令人遗憾的副作用,因此当您使用长命令时它们会重叠.
任何拥有魔法PS1技能的人都可以帮我解决这个问题吗?