I'm using a C# program to retrieve table's data from SAP, the .dll files I used is from SAP .NET CONNECTOR, I got an issue when calling below statements:
RfcDestination destination = RfcDestinationManager.GetDestination(cmbAsset.Text);
readTable = destination.Repository.CreateFunction("RFC_READ_TABLE");
Error message is:
“SAP.Middleware.Connector.RfcInvalidStateException”: Unhandled Exception occurred in sapnco.dll
Other information: Lookup of function RFC_READ_TABLE metadata failed for destination PP1
The thing is, I have several items in combobox 'cmbAsset', for some items above statements executed normally but for others they didn't. Besides, I've set the attibutes of sapnco.dll and sapnco_utils.dll as 'copy to local=true', is there anything wrong? Thanks in advance!
Have you tried other RFC-functions? Are you getting the same issues? Maybe some access-rights are missing? Can you access transaction SE16? You could also try using the Business Blue Print (BBP)-ReadTable. It has some advantages and is newer.
Related
I have an issue with pdftron, where opening a certain file, will cause our application to crash with following error:
An unhandled exception of type 'pdftron.Common.PDFNetException' occurred in PDFNet.dll
Additional information: Exception:
Message: Missing resource
Conditional expression: res
Filename : ContentResources.hpp
Function : trn::PDF::ContentResources::GetResource
Linenumber : 26
In our code: it's in the following line that the error occurs:
while ((element = elReader.Next()) != null)
When doing try/catch, we see that the only thing missing from the page is the text that's written diagonally on that page. Does this have anything to do with a missing font maybe ? Don't mind the cursor in the picture, it doesn't know where to go with the text missing.
I can send the pdf file on request.
PDF File
If you are not on the latest version of PDFNet, 6.7.1, then I would first try against that, as the issue might have been resolved already.
Otherwise, since the issue is document specific, you would need to provide that, by either sharing here, or sending to pdftron support.
I'm trying to read an ESE database (.edb) using the ManagedEsent libraries. However, I'm getting an error at the time of setting up the database. The error appears to be coming up at the time of attaching the database (calling JetAttachDatabase()).
The error message I'm getting is "Soft recovery is intended on a backup database. Restore should be used instead".
Below is my code:
JET_INSTANCE instance;
JET_SESID sesid;
Microsoft.Isam.Esent.Interop.SystemParameters.DatabasePageSize = 8 * 1024;
Api.JetCreateInstance(out instance, Guid.NewGuid().ToString());
Api.JetInit(ref instance);
JET_DBID dbid;
JET_COLUMNID columnid;
JET_TABLEID tableid;
JET_COLUMNDEF columndef = new JET_COLUMNDEF();
Api.JetBeginSession(instance, out sesid, null, null);
Api.JetAttachDatabase(sesid, #"Blah.edb", AttachDatabaseGrbit.None);
Api.OpenDatabase(sesid, #"Blah.edb", out dbid, OpenDatabaseGrbit.None);
The exception I'm getting is:
Microsoft.Isam.Esent.Interop.EsentSoftRecoveryOnBackupDatabase
Soft recovery is intended on a backup database. Restore should be used instead
at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in e:\src\codeplex_svn\codeplex\EsentInterop\Api.cs:line 2894
at Microsoft.Isam.Esent.Interop.Api.JetAttachDatabase(JET_SESID sesid, String database, AttachDatabaseGrbit grbit) in e:\src\codeplex_svn\codeplex\EsentInterop\Api.cs:line 372
Any ideas what could be causing this? Is the .edb file I'm attaching possible invalid?
I was able to access the database after running the EsentUtl utility to repair the database file:
esentutl /p Blah.edb
After running this, I can attach/open the database and read from the tables in the database.
I'm not sure what the repair has actually done to the file though (e.g. if it is possibly now missing some data or something).
Where did you get the database?
What you did should work for a Cleanly-shut-down database. You don't need the transaction log files for these databases.
But there are also Dirty databases (when JetTerm didn't complete gracefully). You'll need the transaction log files for those.
And also Backed-up databases, which are slightly different again. For these databases, you need to call JetRestore.
-martin
Using Windows Serives Bus (not the cloud version), I'm trying to rename a topic programatically, so far I have
internal void UpdateTopic(Topic Topic)
{
Topic dbTopic = TopicManager.GetTopicById(Topic.Id);
TopicDescription topicDescription = _namespaceManager.GetTopic(dbTopic.Name);
topicDescription.Path = Topic.Name;
topicDescription.Status = Topic.Active ? EntityStatus.Active : EntityStatus.Disabled;
_namespaceManager.UpdateTopic(topicDescription);
...
The line _namespaceManager.UpdateTopic(topicDescription); throws Exception The remote server returned an error: (404) Not Found. Not Found.TrackingId:[some tracking id including a GUID],TimeStamp:20/12/2013 13:29:47
Questions:
- Can I actually rename a topic programmatically?
If yes:
- Any idea of what causes the exception?
Rename of a Topic is not supported. You can do Create, Update and Delete operations but since the name is the identifier of the particular resource it cannot be modified. There are several other properties on a TopicDescriptiontoo that cannot be modified, but only set at the time of creation (such as Size).
I have inherited an application that runs small reports locally using Microsoft Web ReportViewer. Our application allows you to "Preview/Print" a report by clicking on a specific button that routes the user to a URL that allows them to download the report as a PDF. We have recently received the requirement to save these PDFs to the document table in our database. I have been able to get this to work successfully on localhost; however, when I publish the application to our IIS server, I get the following error:
System.Data.SqlClient.SqlException: Login failed for user 'Domain\Servername$'.
I've reviewed all of the sites that I could find involving this error (including this one) - most point to adding the server account to the SQL database; however, this shouldn't be an issue, since the button to preview/print the document is still functional and works as expected when the application is published and all of the data is held in a local object, which was previously pulled from the database (the model parameter below). The button and the auto-generation feature use the same two methods to create the PDF document(see below).
Here's some code:
public static byte[] CreatePDFDocument(DocumentTemplateType template, Request model)
{
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportEmbeddedResource = "Xxx.Xxx.Bll.ReportViewerRDLCs." + template.RdlcFilename;
switch ((DocumentType)template.DocumentTypeId)
{
case eDocumentType.Report1:
viewer.LocalReport.SetParameters(GetForm1Parameters(model));
break;
/**
* Several other reports are in this switch. All reports have the
* same issue - all but one are removed for brevity.
*/
}
byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
return bytes;
//return new byte[5] {5,6,7,8,9}; - used for troubleshooting.
}
public static List<ReportParameter> GetReport1Parameters(Request model)
{
List<ReportParameter> rptParams = new List<ReportParameter>();
//Start comment
rptParams.Add(new ReportParameter("EmployeeFullName", string.Format("{0:NN}", model.Employee)));
rptParams.Add(new ReportParameter("EmployeePhoneNumber", string.Format("{0:(###) ###-####}", Convert.ToInt64(model.Employee.PhoneNumber))));
rptParams.Add(new ReportParameter("HrchyShortDesc", model.Employee.HrchyShortDesc));
rptParams.Add(new ReportParameter("RequestDate", model.RequestDate.ToShortDateString()));
rptParams.Add(new ReportParameter("RequestRequested", model.RequestRequestType));
rptParams.Add(new ReportParameter("ReasonForRequest", model.RequestRequestReason));
rptParams.Add(new ReportParameter("LogNumber", model.CaseId));
if (!string.IsNullOrWhiteSpace(model.TimeSensitiveReason)) rptParams.Add(new ReportParameter("TimeSensitiveReason", model.TimeSensitiveReason));
var lastAction = model.LastActionOfType(WorkflowStateActionType.EmployeeConfirmation);
if (lastAction != null)
{
rptParams.Add(new ReportParameter("TodaysDate", lastAction.ActionDate.ToShortDateString()));
rptParams.Add(new ReportParameter("EmpConfirmed", "true"));
}
else rptParams.Add(new ReportParameter("TodaysDate", DateTime.Now.ToShortDateString()));
//end comment
return rptParams;
}
Through a lot of commenting in and out and pushes to our server, I've deduced the following:
From what I can tell, the error occurs on calling GetReport1Parameters. In the code above, I included a start and end comment - I've commented out everything in between, leaving only the list initialization and return statement (of an empty list) and still received the error.
I've commented out the call to GetReport1Parameters and returned a nonsensical byte array and didn't receive an Exception.
All functionality works fine on localhost and when I step through the functions, all of the variables seem to appear normal.
Things I've tried to do to remedy the situation:
1. Removed connection strings from the app.config, so that the application has to go to the web.config to get the correct strings (even though they were the same).
2. Commented in and out different sections of code to determine the problem area.
3. Tried calling the GetReport1Parameters method and returning null, leading to a null reference exception.
4. Tried calling the GetReport1Parameters with an empty parameter list, leading to the error mentioned above.
5. Tried running the report with no parameters (not even a blank list), got a ReportProcessingException for missing params.
Some additional information:
We use a service account for the application using impersonate identity in the web.config. That line is commented out on localhost, but is running on IIS.
All of other database interaction works correctly.
All of our database interaction is done using LINQ to SQL - model is an object based off of a database table, with some additional information that is calculated dynamically.
My desired outcome is that both the autogenerated documents and the preview/print documents both work. I have a feeling that this may be something simple that I'm overlooking, but I've already spent several hours today trying to fix this.
I can't think of any other pertinent information, but if you have questions I'll be more than happy to answer them.
Edit: Additional attempts to find solution:
Tried setting LINQ Deferred Loading equal to false. This caused more problems than it solved.
Implemented IReportServerCredentials and assigned the ReportViewer's ServerReport.ReportServerCredentials with the correct database credentials.
Assigned all pertinent report parameters to a Dictionary, and then called .ToString() on every object to ensure that it is pulled from the database. Then assigned those strings from the dictionary to the report parameters, so that ReportViewer should be receiving the data from the string pool, as opposed to pulling it from the database.
Even though you are using an ObjectDataSource to pass data to your report, Report Viewer will still invoke the Select method, which in turn could cause database access to occur. So even though it may seem that the login is unnecessary, you would need to dig into the data access methods you supplied with your ObjectDataSource to know for sure.
The error you are getting is being caused by a bug in Report Viewer 2010 that is describe in the following Microsoft Connect article:
ReportViewer.LocalReport.Render and ReportViewer.LocalReport.SetParameters changes ImpersonationLevel to None
Although the article mentions this problem should be fixed in Service Pack 1, it does not appear to be the case. I have not verified if this problem is fixed in Report Viewer 2012.
I worked around the problem by changing my data access layer to compare the current identity against the one in my HttpContext and restore it if necessary using the following code snippet:
System.Security.Principal.IIdentity id = System.Web.HttpContext.Current.User.Identity
if (id.Name != System.Security.Principal.WindowsIdentity.GetCurrent().Name)
{
context = (id as System.Security.Principal.WindowsIdentity).Impersonate()
}
I do this right before I connect to the database and undo it as soon as the connection is open.
I am not exactly thrilled with this workaround, mainly because now my data access layer is referencing the UI layer (System.Web).
I am trying to use the following code in my project. http://www.codeproject.com/KB/miscctrl/imapi2.aspx
However, When I run the application and click on "Detect Media" it says "Media not supported".
Can someone please help me with this issue. Why does it say Media not supported?
Thank you,
Divya.
Referring to Eric's source code for the application, this text comes from the buttonDetectMedia_Click method in the MainForm class:
discFormatData = new MsftDiscFormat2Data();
if (!discFormatData.IsCurrentMediaSupported(discRecorder))
{
labelMediaType.Text = "Media not supported!";
_totalDiscSize = 0;
return;
}
So, the call to IsCurrentMediaSupported is failing. This is actually a COM Interop call to IDiscFormat2::IsCurrentMediaSupported. The MSDN documentation does mention some other possible HRESULT values, though I'd expect that if they occurred, a COMException would be thrown. The sample code does catch this exception, in which case a message box is displayed - that's not the case here though.
When I ran the sample, I got the same "Media not supported!" error. I have a DVD burner, but there is no disc in the drive (don't have any blank discs with me at the moment!), so that appears to be one answer to why you'd get that message. I'd guess if the media in the drive was not writable or incompatible with your burner, you'd also get that message.