I am trying to subscribe to CheckinEvent, for some reason my Notify method isn't called.
This is my contract -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace TFSubscriber
{
[ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public interface IRollupService
{
[OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document)]
void Notify(string eventXml, string tfsIdentityXml);
}
}
My implementation is pretty simple, empty method. I put a breakpoint in my Notify method and it's not called.
This how I subscribe to CheckinEvent -
C:\Program Files\Microsoft Team Foundation Server2010\Tools>bissubscribe.exe /eventType CheckInEvent /address http://localhost:4556/Rollupservice.svc /collection http://localhost:8080/tfs/defaultcollection
I have a solution that I added to source control already, and I am checkin' some files and the breakpoint isn't getting hit.
What am I doing wrong?
Are you sure your subscription works? For example try logging some information regarding input parameter eventXML. Because, you need to be sure about if your subscription works or not. If so, you can run your SVC project and attach a debugger on it. That is how debugger supposed to hit your breakpoint.
Related
I have an asp.net core application hosted and webdav enabled in IIS for storing files as well. I want to know when a user saves a file in the webdav server (ie, if opened and saved in Microsoft word). I have put together this IIS module to try and intercept all http requests so I can find out what a webdav HTTP requests look like and then hopefully create a if statement using this logic once I can identify the save request. So far here is the IIS module I have created:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace WebDAVTargetDetectorIIS
{
public class LoggingModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
context.PostLogRequest += new EventHandler(PostLogEvent);
}
#endregion
public void OnPreRequestHandlerExecute(Object source, EventArgs e)
{
HttpApplication app = (HttpApplication)source;
HttpRequest request = app.Context.Request;
if (!String.IsNullOrEmpty(request["HTTP_CF_CONNECTING_IP"]))
{
request.ServerVariables.Set("REMOTE_ADDR", request["HTTP_CF_CONNECTING_IP"]);
}
}
public void PostLogEvent(Object source, EventArgs e)
{
HttpApplication app = (HttpApplication)source;
HttpRequest request = app.Context.Request;
app.Response.AppendToLog("This is a test");
}
}
}
I have created the BIN folder in the root folder of my web application and used the IIS Manager to add the new module. It is added to the end of the ordered list. The log files in IIS seem to save to "C:\inetpub\logs\LogFiles\W3SVC1" however my module does not seem to be printing my test line in there. Is there a particular reason the code above would not implement on any even a login request? Or should I be attaching this to some other event?
I was curious about how I can call .net libraries from a C++ console application using the newer C++/WinRT using C++17 language projections. But I find that it’s hard to find even a hello world example of this.
How would I create an equivalent console application in C++/WinRT as this simple C# hello world program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoApplication
{
class Program
{
static void Main(string[] args)
{
Console.Write("Hello World");
Console.ReadKey();
}
}
}
I guess you need to use c++/cx instead of c++/WinRT, since c++/cx let’s you access .net and c++/WinRT only lets you access the UWP version of .net called runtime components:
#using <mscorlib.dll>
using namespace System;
int main(array<System::String ^> ^args)
{
System::Console::WriteLine("Hello world");
return 0;
}
I have a simple ASMX WebService and it just looks like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Web;
using System.Web.Services;
using System.Xml.Serialization;
namespace ContractGenerationTest
{
[WebService(Namespace = Constants.WebServiceNamespace)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Standard : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hellow World";
}
}
}
I also have a WCF Client that is associated with the service. The "Always generate message contracts" checkbox is unchecked. The WCF Client is generating message contract classes even though I do not want it to.
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://sampleuri.org/ContractGenerationTest/", ConfigurationName="StandardService.StandardSoap")]
public interface StandardSoap {
// CODEGEN: Generating message contract since element name HelloWorldResult from namespace http://sampleuri.org/ContractGenerationTest/ is not marked nillable
[System.ServiceModel.OperationContractAttribute(Action="http://sampleuri.org/ContractGenerationTest/HelloWorld", ReplyAction="*")]
ContractGenerationTestClient.StandardService.HelloWorldResponse HelloWorld(ContractGenerationTestClient.StandardService.HelloWorldRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://sampleuri.org/ContractGenerationTest/HelloWorld", ReplyAction="*")]
System.Threading.Tasks.Task<ContractGenerationTestClient.StandardService.HelloWorldResponse> HelloWorldAsync(ContractGenerationTestClient.StandardService.HelloWorldRequest request);
}
Note the CODEGEN comment. This seems to be constructed this way because the string type is not marked as nillable in the WSDL from the ASMX service. It is not marked as nillable (nor has maxOccurs=1) because string.Empty provides a default value.
If the strings were members of a complex type, I could just mark them as [XmlElement(IsNullable=true)] and that would solve the problem... but I can't do that here because they are part of the function definition.
Is there a known solution to this? Is there a way I can get my ASMX to mark the string parameters and return types as nillable in the WSDL? Or is there a way for my WCF Client to stop generating message contracts even if there are non-nillable parameter types (knowing this will remove parameter optionality)?
I found a solution for this. Looks like it is a result of using the DataContractSerializer which is selected by default. There's no fix for this in the GUI provided in Visual Studio. To configure this manually, open the Reference.svcmap file on the client side of the service and change <Serializer>Auto</Serializer> to <Serializer>XmlSerializer</Serializer>.
This caused the VS to stop generating message contracts.
I tried to follow a tutorial on SignalR 2.0. with ASP.NET MVC 4.0
I build the new Startup class as instructed.
using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(MyApp.Startup))]
namespace MyApp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
app.MapSignalR();
}
}
}
When I tried to build the project. I got The namespace 'MyApp' already contains a definition for 'Startup' .
I have search the whole project and physical folders to find where the second Startup,cs is but I could not find it.
Can anyone share some light on this?
Thanks,
I found the duplicate. It was defined in BundleConfig.cs. Removed it from BundleConfig.cs and it builds fine. Thanks,
Try making your Startup class partial:
public partial class Startup
Here's my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using BankServiceClient.BankServiceReference;
namespace BankServiceClient
{
class Program
{
static void Main(string[] args)
{
Uri baseAddress = new Uri("http://localhost:8000/Simple");
Type instanceType = typeof(BankServiceReference.BankClient);
ServiceHost host = new ServiceHost(instanceType,baseAddress);
using (host)
{
Type contractType = typeof(BankServiceReference.IBank);
string relativeAddress = "BankService";
host.AddServiceEndpoint(contractType, new BasicHttpBinding(), relativeAddress);
host.Open();
Console.WriteLine("Press <ENTER> to quit.");
Console.ReadLine();
host.Close();
}
/*
* Consuming a WCF Service and using its method.
*/
//IBank proxy = new BankClient();
//double number = proxy.GetBalance(1234);
//Console.WriteLine(number.ToString());
//Console.ReadLine();
}
}
}
First, a couple of questions:
The 'baseAddress' attribute, what exactly is it? When I launched my service using the default F5 (no console application) the service launched on a random port on localHost. How can I write in an exact number and expect it to go there? Confused at this one.
What is the relativeAddress attribute? It says BankService but what should I write in that attribute? Confused at this one as well.
Here's the exact error message I get when I try to run this Console application:
HTTP could not register URL
http://+:8000/Simple/. Your process
does not have access rights to this
namespace (see
http://go.microsoft.com/fwlink/?LinkId=70353
for details).
First is your client project set to be the start up project?
And to answer your questions.
1) baseAddress (URI Class) is the base address for your hosted service. I am thinking you are launching some other project.
2) You have two options on configuring endpoints(reference). Relative and Absolute. The way you did it will take your base and appends your relative -> http://localhost:8000/Simple/BankService
Lastly to fix your hosting issue see this SO link:
WCF ServiceHost access rights