I am trying to read an XML file in RIA Service and I am getting the following error.
Load operation failed for query 'GetSummaryList'. Could not find a part of the path 'C:\WINDOWS\SYSTEM32\CoreResources\SumaryListDS.xml'.
I am using Silverlight 4 which is using RIA service. I am trying to read the SumaryListDS.xml located in the bin\CoreResources folder. But the application insted of looking for the file under bin\CoreResources, its trying to read it from C:\WINDOWS\SYSTEM32\CoreResources.
I am just wondering how to read a file using relative path in RIA Service with Silverlight front end?
Thanks,
Vinod
You should be able to use .. to go up one directory, such as ../CoreResources/GetSummaryList.xml
Here is how I resolved my problem. Its been implemented in one of the layers of business tier, which can be used by variety of clients (ASP.NET, Console App, Windows Client, Silverlight hosted inside ASP.NET). So when GetSummaryXml is called, previously it used to be
public DataSet GetSummaryXml()
{
var dsReport = new DataSet("Report");
var summaryListXmlPath = "CoreResources/SumaryListDS.xml";
dsReport.ReadXml(summaryListXmlPath);
return dsReport;
}
I started getting an error when I started consuming it in RIA Domain Service to be used by Silverlight 4 client.
ERROR:
Load operation failed for query
'GetSummaryList'. Could not find a
part of the path
'C:\WINDOWS\SYSTEM32\CoreResources\SumaryListDS.xml'.
But SumaryListDS.xml located in the bin\CoreResources, not WINDOWS\SYSTEM32\CoreResources
So I modified GetSummaryXml to...
public DataSet GetSummaryXml()
{
var dsReport = new DataSet("Report");
var currContext = HttpContext.Current;
var summaryListXmlPath = "CoreResources/SumaryListDS.xml";
if (currContext != null)
summaryListSchemaPath = currContext.Server.MapPath(#"../bin/" + summaryListXmlPath);
dsReport.ReadXml(summaryListXmlPath);
return dsReport;
}
And now its working fine. I am not sure if this is a perfect solution thou.
Related
I am using VS 2019 to develop core.net web Api. I am trying to read the all methods and Parameters inside my controller. I am using Repository pattern to develop API.
Below is the code from my repository.
var method = MethodBase.GetCurrentMethod();
_log4net.Info("Assembly Name : " + Assembly.GetCallingAssembly().FullName);
_log4net.Info("Method Name : " + method.Name);
_log4net.Info("Repository Name :" + method.ReflectedType.FullName);
var result =
((System.Reflection.TypeInfo)Assembly.GetCallingAssembly().GetTypes().Where(type
=> type.FullName.Contains("AsmeController")).FirstOrDefault()).DeclaredMethods;
_log4net.Info(result);
Log's:
In Debug Mode:
After deployment in IIS
This code is working as expected and returns the list of Method Info in Debug mode and not working and return Null in Release mode even after deployed in IIS.
As i observed using logs, Assembly name was changing Demo.dll to “ Assembly Name : Anonymously Hosted DynamicMethods Assembly “ after deployment.
Please give me suggestions to solve this problem.
For the work around i am directly reading the application dll, Instead of reading current assembly. So that i can able to access the all info from there.
string assemblyFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location + "\\Demo.dll");
Assembly testAssembly = Assembly.LoadFile(assemblyFile);
var result = ((TypeInfo)testAssembly.GetTypes().Where(type => type.FullName.Contains("AsmeController")).FirstOrDefault()).DeclaredMethods;
I am in the progress of rewriting some code to work with ASP 5.
The old code does the following:
string Local_IP=Request.ServerVariables["LOCAL_ADDR"];
string HTTP_reverse_VIA = Request.ServerVariables["HTTP_REVERSE_VIA"];
How do I get the corresponding information from ASP 5?
HttpContext has the GetFeature method, using this method we can get feature information.
Here we are want to get Server Variables of IIS; check project.json "Microsoft.AspNet.Server.IIS" is used for running ASP.NET 5.
We have to use GetFeature of 'Microsoft.AspNet.Server.IIS' which contains Server variables feature. use the below code
var varibleFeature = Context.GetFeature<Microsoft.AspNet.Server.IIS.Features.IServerVariablesFeature>();
if (varibleFeature != null)
{
var valuesList = varibleFeature.ServerVariables;
//read through valuesList dictionary for Server Variables
}
Since I was running on IIS Express, it gave few variables but not the one mentioned in your question.
Please deploy it on IIS and explore more.
Application: Connecting to BigQuery using BigQuery APIs for Java
Environment: Eclipse, Windows 7
My application was running fine until last night. I've made no changes (except for restarting my computer) and my code is suddenly giving me this error:
Application name is not set. Call Builder#setApplicationName.
Thankfully I had a tar'd version of my workspace from last night. I ran a folder compare and found the local_db.bin file was different. I deleted the existing local_db.bin file and tried to run the program again. And it worked fine!
Any idea why this might have happened?
Hopefully this will help anyone else who stumbles upon this issue.
Try this to set your application name
Drive service = new Drive.Builder(httpTransport, jsonFactory, null)
.setHttpRequestInitializer(credential)
.setApplicationName("Your app name")
.build();
If you are working with only Firebase Dynamic Links without Android or iOS app
Try this.
builder.setApplicationName(firebaseUtil.getApplicationName());
FirebaseUtil is custom class add keys and application name to this class
FirebaseDynamicLinks.Builder builder = new FirebaseDynamicLinks.Builder(
GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), null);
// initialize with api key
FirebaseDynamicLinksRequestInitializer firebaseDynamicLinksRequestInitializer = new FirebaseDynamicLinksRequestInitializer(
firebaseUtil.getFirebaseApiKey());
builder.setFirebaseDynamicLinksRequestInitializer(firebaseDynamicLinksRequestInitializer);
builder.setApplicationName(firebaseUtil.getApplicationName());
// build dynamic links
FirebaseDynamicLinks firebasedynamiclinks = builder.build();
// create Firebase Dynamic Links request
CreateShortDynamicLinkRequest createShortLinkRequest = new CreateShortDynamicLinkRequest();
createShortLinkRequest.setLongDynamicLink(firebaseUtil.getFirebaseUrlPrefix() + "?link=" + urlToShorten);
Suffix suffix = new Suffix();
suffix.setOption(firebaseUtil.getShortSuffixOption());
createShortLinkRequest.setSuffix(suffix);
// request short url
FirebaseDynamicLinks.ShortLinks.Create request = firebasedynamiclinks.shortLinks()
.create(createShortLinkRequest);
CreateShortDynamicLinkResponse createShortDynamicLinkResponse = request.execute();
I'm new to Silverlight. My code works in Window Forms:
static void Main()
{
DBConnect dbconnect = new DBConnect();
using (System.IO.StreamWriter file = new System.IO.StreamWriter(#"C:\Temp\WriteLines4.txt", true))
{
file.WriteLine(dbconnect.CountPublic());
}
dbconnect.CloseConnectionPublic();
}
It connects to database, counts rows in table, writes result into txt file and closes connection.
Now my need is to show result in silverlight (web page) instead of writing into txt file. How do I start?
UPDATE:
Silverlight doesn't work with database directly. My need is to create WCF service for work with database and consume service using Silverlight.
Found simple example for SL & WCF to start with:
http://sonyarouje.com/2010/10/16/image-uploading-retrieving-silverlight-and-wcf/
My issue seems to be related to permissions, but I am not sure how to solve it.
In the FeatureActivated event of one of my features I am calling out to a class I created for managing webconfig entries using the SPWebConfigModification class. The class reads up an xml file that I have added to the mapped Layouts folder in the project.
When I deploy the .wsp to my Sharepoint server everything gets installed fine, but when the FeatureActivated event runs it throws a 503 error when attempting to access the xml file.I am deploying the .wsp remotely using a powershell script and I have the powershell, the iisapp pool and the owstimer.exe all using the same domain administrative user.
I assumed the issue was that the FeatureActivated event code was being run within the scope of the OWSTIMER.exe so changed the logon of the service to a domain user that has administrative access to the server to see if that would solve the problem, but no matter what I am getting the 503.
I have traced out the URL to the xml file and pasted that into IE and I am getting back the xml without issue from the server once its copied.
Can anyone give me any idea where to look to figure out why the FeatureActivated event code can't seem to get to the XML file on the server?
Below is the code in my class that is being called from the FeatureActivated event to read the xml.
_contentservice = ContentService;
WriteTraceMessage("Getting SPFeatureProperties", TraceSeverity.Medium, 5);
_siteurl = properties.Definition.Properties["SiteUrl"].Value;
_foldername = properties.Definition.Properties["FolderName"].Value;
_filename = properties.Definition.Properties["FileName"].Value;
_sitepath = properties.Definition.Properties["SitePath"].Value;
WriteTraceMessage("Loading xml from layouts for configuration keys", TraceSeverity.Medium, 6);
xdoc = new XDocument();
XmlUrlResolver resolver = new XmlUrlResolver();
XmlReaderSettings settings = new XmlReaderSettings();
StringBuilder sb = new StringBuilder();
sb.Append(_siteurl).Append("_layouts").Append("/").Append(_foldername).Append("/").Append(_filename);
WriteTraceMessage("Path to XML: " + sb.ToString(), TraceSeverity.Medium, 7);
WriteTraceMessage("Credentials for xml reader: " + CredentialCache.DefaultCredentials.ToString(), TraceSeverity.Medium, 8);
resolver.Credentials = CredentialCache.DefaultCredentials; //this the issue might be here
settings.XmlResolver = resolver;
xdoc = XDocument.Load(XmlReader.Create(sb.ToString(), settings));
I finally punted on this issue because I discovered that while adding the -Force switch to the Enable-SPFeature command did use a different process to activate the feature when adding a solution it did not work when updating a solution. Ultimately I just changed my XDocument.Load() to use a TextReader instead of a URI. The xml file will always be available when deploying the WSP because it is part of the package so there is no reason to use IIS and a webrequest to load up the xml.