Well, it's been several hours I'm lost...
IXSLTemplate::putref_stylesheet doesn't document any error except E_FAIL.
However in my case putref_stylesheet returns E_INVALIDARG. GetErrorInfo() is only redundant telling me that the "Argument is invalid". So I am not left with much information.
However my code is pretty close to all examples I found on the web and msdn.
And it does something like:
void xsltProcessing(MSXML2::IXMLDOMDocument* pXmlDoc, MSXML2::IXMLDOMDocument * pXslDoc)
{
IXSLTemplatePtr pTemplate;
pTemplate.CreateInstance( _T( "Msxml2.XSLTemplate" ));
pTemplate->putref_stylesheet(pXslDoc);
//...
}
As there is not much documentation for putref_stylesheet. Do you have any idea what could go wrong for it to return E_INVALIDARG ?
My pXslDoc is a IXMLDOMDocument I have loaded from static const strings with success.
Any clue ? ( I guess it's pretty vague a question, but it's been hours I am searching )
Are you loading pXslDoc asynchronously perhaps?
The default behaviour for IXMLDOMDocument objects is to load asynchronously, so it is possible that the pXslDoc has not finished loading when you call putref_stylesheet().
Adding the following code before you load pXslDoc would fix this problem, if it is what you are suffering from:
pXslDoc->put_async(VARIANT_FALSE);
Related
I've been writing Lua integration into a game project, and frustratingly, every time I try and use lua_pcall, I get the error "attempting to call nil value."
When I try to look up the error, most of the examples are of people who have forgotten to use pcall after loading their lua file, or some error down the line. But for me, it's as soon as I even attempt to load the lua standard libs. I don't understand what's going wrong with so little code to show for it. Other things I've tried are skipping openLibs and going straight to loading my file with doFile, but even in that case, anything I do at all will result in a nil error.
Any help is greatly appreciated.
EDIT:
Thanks to some help I determined that I didn't need to do a pcall for luaL_openlibs, but as I wrote above, trying to run any function at all results in errors. In this case, it can't find "init" in the global lua namespace
c++
void LuaScriptingInterface::init()
{
m_luaState = std::shared_ptr<lua_State>(luaL_newstate());
luaL_openlibs(m_luaState.get());
if (luaL_dostring(m_luaState.get(), m_script.c_str())) // script below
{
const char* errStr = lua_tostring(m_luaState.get(), -1);
ASSERT(false, errStr ); // not hitting this case
}
lua_getglobal(m_luaState.get(), "init");
if (!lua_isfunction(m_luaState.get(), -1))
{
ASSERT(false); // hit this case! Why can't we find "init"?
}
}
lua
init function ()
end
update function (dt)
end
It doesn't do anything yet of course, but I expect it should at least be able to find the function.
Hilariously the issue was in my FileReader code, there was an omitted newline character
This is my code in order to get the name of the item which has been selected in my CListViewCtrl:
LVITEM item = { LVIF_PARAM };
CString itemText;
clistViewCtrl.GetSelectedItem(&item);
clistViewCtrl.GetItemText(item.iItem, item.iSubItem, itemText);
Note that this code is working. I recently did another project, where I grabbed the name in exactly this way, however, I had no problems there with any assertion fails.
When I execute this with my current project, I always get a debug assertion:
"File: ... atlctrls.h"
Line: 3242
Expression: (GetStyle() & 0x0004) != 0
Even though the expression already states it pretty much, here is the line causing the failure:
ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0);
I have barely any idea what the problem is. As I said, the exact same code worked on my other project, and I just went through both, trying to find any differences which could cause this behaviour, but nothing caught my eye.
Honestly, I don't even know if this is related to my code at all, considering the two compared elements seem to be predefined.
My first guess would have been that this part is being called before the items are created, but all items in the listview are created at the point I try to call this code passage.
Can anyone point me to a solution?
Your control is not created with style flag LVS_SINGLESEL. So calling GetSelectedItem is causing an assert. In case of multi selection use GetFirstSelectedItem and GetNextSelectedItem instead of GetSelectedItem. For single selection you can continue useing GetSelectedItem, but you have to add LVS_SINGLESEL style flag to your control.
The following EndDraw() function returns an HRESULT error code:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd371924%28v=vs.85%29.aspx
The documentation specifies:
If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code and sets tag1 and tag2 to the tags that were active when the error occurred.
...and then returns an HRESULT indicating the success of the operations...
I am getting a return value of -2003238911 (0x88990001) which doesn't appear on Microsoft's "Common HRESULT values" page:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa378137%28v=vs.85%29.aspx
I have also searched for the error code in WinError.h but can't find it there either. If it returns this code, there must be a way to find out what it means.
How do I interpret this error code to find out what went wrong?
You use the Google, on which the top result for that hex code has this:
D2DERR_WRONG_STATE
0x88990001
The object was not in the correct state to process the method.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd370979(v=vs.85).aspx
I don't know the first thing about graphics programming or Windows programming, but I think this answers your question, combined with the docs stating that the tag values will be given back to you referring to the point where the error occurred.
Last but not least..
I got the same error, till i realized that i wasn't calling ID2D1HwndRenderTarget::BeginDraw() first in order to prepare the render target for draw calls.
(I just created an account to vote up the answer by Loul G. but I don't have permission to vote yet...)
I have had this same issue...
When BeginDraw() and EndDraw() are called out of order you can get HRESULT: 0X88990001
Trace back to see the order in which they are called.
Also, to help protect against this you can surround BeginDraw(), EndDraw() calls like:
bool beginCalled;
int beginCount;//for debugging
int endCount;//for debugging
//initialize variables somewhere...
void begin(){
rendTarget>BeginDraw();
beginCalled = true;
beginCount++;
}
void end(){
if(beginCalled){
rendTarget->EndDraw();
beginCalled = false;
}
endCount++;
}
//print counts as necessary for debugging
So I'm trying to make use of a GtkSourceView in C++ using GtkSourceViewmm, whose documentation and level of support give me the impression that it hasn't been very carefully looked at in a long time. But I'm always an optimist :)
I'm trying to add a SourceView using some code similar to the following:
Glib::RefPtr<gtksourceview::SourceLanguageManager> source_language_manager = gtksourceview::SourceLanguageManager::create();
Glib::RefPtr<gtksourceview::SourceLanguage> source_language = Glib::wrap(gtk_source_language_manager_guess_language(source_language_manager->gobj(), file, NULL));
Glib::RefPtr<gtksourceview::SourceBuffer> source_buffer = gtksourceview::SourceBuffer::create(source_language);
gtksourceview::SourceView* = m_source_view = new gtksourceview::SourceView(source_buffer);
m_vbox.pack_start(*m_source_view);
Unfortunately, it spits out the warning
(algoviz:4992): glibmm-WARNING **:
Failed to wrap object of type
'GtkSourceLanguage'. Hint: this error
is commonly caused by failing to call
a library init() function.
and when I look at it in a debugger, indeed the second line above (the one with the Glib::wrap()) is returning NULL. I have no idea why this is, but I tried to heed the warning by adding Glib::init() to the begining of the program, but that didn't seem to help at all either.
I've tried Google'ing around, but have been unsuccessful. Does anyone know what Glib wants me to init in order to be able to make that wrap call? Or, even better, does anyone know of any working sample code that uses GtkSourceViewmm (not just regular GtkSourceView)? I haven't been able to find any actual sample code, not even on Google Code Search.
Thanks!
It turns out, perhaps not surprisingly, that what I needed to init was:
gtksourceview::init();
After this, I ran into another problem with one of the parameter to gtksourceview::SourceLanguageManager, but this was caused by a genuine bug which I subsequently reported and was promptly fixed. So everything's working great now!
I use gtkmm. Typically you have to initialize things with something like :
_GTKMain = new Gtk::Main(0, 0, false);
Of course do not forget :
delete _GTKMain;
Check here for details :
http://library.gnome.org/devel/gtkmm/2.19/classGtk_1_1Main.html
(Sorry but the link option does not work ...)
I am writing an background service application that has to automatically read data from Excel 2003 files. But no matter what I try, the method OlePropertyGet() always results in an EAccessViolation error while trying to read from address "00000800".
The error always occurs at the last line of this code snippet, and seems independent of what parameter the method receives:
Variant excel, workbooks;
try
{
excel = GetActiveOleObject("Excel.Application");
}
catch(...)
{
excel = CreateOleObject("Excel.Application");
}
workbooks = excel.OlePropertyGet("Workbooks");
I've done some extensive google search on this, but found nothing that's even remotely helpful, only this forum thread where someone has the same issue, but doesn't give any information about the cause or solution (it's somewhat funny that at one point the author mentions he knows the cause, but doesn't say what it is!).
I'm open to any ideas as to what is causing this and how to solve this problem, but also alternative approaches to Excel OLE automation.
My guess is its a null pointer issue..
It looks like neither GetActiveOleObject() nor CreateOleObject() worked.
Try checkign the validity of 'excel' before calling OlePropertyGet.
And I guess you should make sure you have Excel installed.
You can use Visual Studio Tools for Office (see http://msdn.microsoft.com/en-us/library/d2tx7z6d.aspx).
Or you can use ATL support to instantiate the object model provided by office.
Your code may not be able to resolve "Excel.Application" successfully, leading to a null pointer. It uses a registry lookup with that string to identify Excel. It sounds like you're missing that registry entry.
I use such code to determine validity of created objects(in C++ Builder):
Varaint excel = GetActiveOleObject("Excel.Application");
TAutoDriver<IDispatch> dispatcher;
dispatcher.Bind(excel, false);
if (dispatcher.IsBound())
{
Variant workbooks = excel.OlePropertyGet("Workbooks");
}